-
Notifications
You must be signed in to change notification settings - Fork 0
/
SchrodingerSmiley.cpp
57 lines (50 loc) · 1.15 KB
/
SchrodingerSmiley.cpp
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
55
56
57
// codechef, SMILEY
#include<bits/stdc++.h>
using namespace std;
// #define ll unsigned long long int;
void solve()
{
int len;
cin>>len;
string schrodinger;
cin>>schrodinger;
bool open = false;
bool presentFrawn = false;
bool presentSmilie = false;
int count=0;
for(int i = 0;i<len;i++){
if(schrodinger[i]==':'){
if(open && !presentFrawn && presentSmilie){
open = false;
count++;
}
if(open && presentFrawn){
open = false;
presentFrawn = false;
}
if(!open){
open = true;
presentFrawn = false;
presentSmilie = false;
}
}
else if(schrodinger[i]=='('&& open)
presentFrawn = true;
else if(schrodinger[i]==')'&& open)
presentSmilie = true;
}
cout<<count<<endl;
return;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int testCases;
cin>>testCases;
while(testCases--)
solve();
return 0;
}