-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBRCKTS.cpp
More file actions
56 lines (54 loc) · 697 Bytes
/
BRCKTS.cpp
File metadata and controls
56 lines (54 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<stdio.h>
int main()
{
int n,m,r,i,j,k,l,count1,count2,q;
char s[300000];
for(i=0;i<10;i++)
{
scanf("%d",&n);
scanf("%s",s);
scanf("%d",&m);
for(j=0;j<m;j++)
{
q=0;
scanf("%d",&r);
if(r!=0)
{
if(s[r-1]==')')
s[r-1]='(';
else
s[r-1]=')';
}
else
{
for(k=0;k<n;k++)
{
if(k!='(')
continue;
count1=0;
count2=0;
for(l=k+1;l<n;l++)
{
if(s[l]=='(')
count1++;
else
{
if(count1==count2)
{
q=1;
break;
}
count2++;
}
}
if(q==1)
break;
}
}
if(q==0)
printf("NO\n");
else
printf("YES\n");
}
}
}