We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent be55e81 commit 5ac0d47Copy full SHA for 5ac0d47
박예진/11주차/260312.cpp
@@ -0,0 +1,36 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+int main() {
5
+ ios_base::sync_with_stdio(false);
6
+ cin.tie(NULL); cout.tie(NULL);
7
8
+ int T;
9
+ cin >> T;
10
+ while(T--) {
11
+ string str;
12
+ cin >> str;
13
14
+ bool flag = true;
15
+ stack <char> s;
16
+ for(auto iter : str){
17
+ if (iter == '(') {
18
+ s.push('(');
19
+ } else {
20
+ if (!s.empty() && s.top() == '(') {
21
+ s.pop();
22
23
+ flag = false;
24
+ break;
25
+ }
26
27
28
29
+ if (s.size()) flag = false;
30
31
+ if (flag) cout << "YES\n";
32
+ else cout << "NO\n";
33
34
35
+ return 0;
36
+}
0 commit comments