-
Notifications
You must be signed in to change notification settings - Fork 1
/
B.cpp
34 lines (27 loc) · 883 Bytes
/
B.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
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
getchar();
while(N--) {
vector<char> braces;
bool ok = true;
char c;
while(scanf("%c", &c), c != '\n') {
if (c == '[' || c == '(' || c == '{') braces.push_back(c);
else if(c == '}' || c == ']' || c == ')') {
if (!braces.empty()) {
if (braces.back() == '[' && c == ']') braces.pop_back();
else if (braces.back() == '{' && c == '}') braces.pop_back();
else if (braces.back() == '(' && c == ')') braces.pop_back();
else ok = false;
}
else ok = false;
}
}
if (ok && braces.empty()) cout << "Compilou\n";
else cout << "Erro de compilacao\n";
}
return 0;
}