mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
120ba634b8
3300-3399
28 lines
581 B
C++
28 lines
581 B
C++
#include<cstdio>
|
|
#include<cstring>
|
|
#include<iostream>
|
|
#include<cmath>
|
|
#include<algorithm>
|
|
using namespace std;
|
|
const int maxn=2005;
|
|
char str[maxn];
|
|
int main(){
|
|
int cas=1;
|
|
while(scanf("%s", str)&&str[0]!='-'){
|
|
int i, ans=0, lef=0;
|
|
for(i=0; str[i]!='\0'; i++){
|
|
if(str[i]=='{'){
|
|
lef++;
|
|
}
|
|
else if(lef>0){
|
|
lef--;
|
|
}
|
|
else {
|
|
ans++;lef++;
|
|
}
|
|
}
|
|
printf("%d. %d\n", cas++, ans+lef/2);
|
|
}
|
|
return 0;
|
|
}
|