-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathANARCO9.cpp
More file actions
28 lines (28 loc) · 832 Bytes
/
ANARCO9.cpp
File metadata and controls
28 lines (28 loc) · 832 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
#include<stdio.h>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
char str[2002];
int left,right,cntr,t=1;
while(1){
left=0;right=0;cntr=0;
scanf("%s",&str);
if(str[0]=='-')break;
int len=strlen(str);
for(int i=0;i<len;i++){
if(str[i]=='{')left++;
else right++;
if(right>left){
left++;
right--;
cntr++;
}
}
if(left>right)cntr+=(int)ceil((left-right-cntr)/2.0);
//else if(right>left)cntr=(right-left)/2;
printf("%d. %d\n",t,cntr);
t++;
}
return 0;
}