-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4949.cpp
More file actions
46 lines (43 loc) · 968 Bytes
/
4949.cpp
File metadata and controls
46 lines (43 loc) · 968 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main()
{
io;
string s;
while(true){
getline(cin,s);
if(s==".") break;
stack<char> op;
bool p=true;
for(char c:s){
if(c=='('||c=='['){
op.push(c);
}
else if(c==')'){
if(!op.empty()&&op.top()=='(')
op.pop();
else {
p=false;
break;
}
}
else if(c==']'){
if(!op.empty()&&op.top()=='[')
op.pop();
else {
p=false;
break;
}
}
}
if(!op.empty()) p=false;
if(p) cout<<"yes\n";
else cout<<"no\n";
}
return 0;
}