-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathANARCO9A_AC.cpp
More file actions
52 lines (52 loc) · 2.4 KB
/
ANARCO9A_AC.cpp
File metadata and controls
52 lines (52 loc) · 2.4 KB
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
#include<stdio.h>
#include<cstring>
int main()
{
char s[2010],st[2010];
int top=0,count,i,count1=0;
count=0;
while(1)
{
scanf("%s",&s);
if(s[0]=='-')
break;
count1++;
count=0;
top=0;
st[top]=1;
for(i=0;i<strlen(s);i++)
{
if(s[i]=='}')
{
if(st[top]!='{')
{
count++;
top++;
st[top]='{';
}
else if(st[top]=='{')
top--;
}
else if(s[i]=='{')
{
if(top+1==strlen(s))
{
if(st[top]=='{')
{
count++;
top--;
continue;
}
}
top++;
st[top]=s[i];
}
}
if(st[top]!=1)
{
count+=top/2;
}
printf("%d. %d\n",count1,count);
}
return 0;
}