-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9012.cpp
More file actions
37 lines (34 loc) · 765 Bytes
/
9012.cpp
File metadata and controls
37 lines (34 loc) · 765 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
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main() {
stack<int> stack;
int num;
string par;
int flag;
cin >> num;
for (int i = 0; i < num; i++) {
flag = 0;
cin >> par;
for (int j = 0; j < par.size(); j++) {
if (par.at(j) == '(')
stack.push(1);
else {
if (stack.empty()) {
flag = 1;
break ;
}
stack.pop();
}
}
if (stack.empty() && flag != 1)
cout << "YES" << endl;
else {
cout << "NO" << endl;
while (!stack.empty())
stack.pop();
}
}
return (0);
}