Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string s;
- int n=0, a=0, b=0;
- cin >> s;
- while (cin >> s) {
- for (auto c : s) {
- if (c == '(') n++;
- else if (c == ')') n--;
- else if (c == '[') a++;
- else if (c == ']') a--;
- else if (c == '{') b++;
- else b--;
- if (a<0 or b<0 or n<0) {
- cout << 0;
- break;
- }
- }
- } if (n==1 and a==1 and b==1) cout << 1;
- else cout << 0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement