-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4949.cpp
35 lines (31 loc) · 808 Bytes
/
4949.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
#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
string a;
while(true){
stack<char> S;
getline(cin,a);
if(a==".") break;
string ans="yes";
for(char input:a){
if(input=='['||input=='(') S.push(input);
else if(input==']'){
if(!S.empty()&&S.top()=='[') S.pop();
else{
ans="no";
break;
}
}else if(input==')'){
if(!S.empty()&&S.top()=='(') S.pop();
else{
ans="no";
break;
}
}
}
if(!S.empty()) ans="no";
cout<<ans<<"\n";
}
}