Advertisement
Zuneve

sec cpp2

Aug 28th, 2022
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main() {
  5. string s;
  6. int n=0, a=0, b=0;
  7. while (cin >> s) {
  8. for (auto c : s) {
  9. if (c == '(') n++;
  10. else if (c == ')') n--;
  11. else if (c == '[') a++;
  12. else if (c == ']') a--;
  13. else if (c == '{') b++;
  14. else b--;
  15. if (a<0 or b<0 or n<0) {
  16. cout << 0;
  17. break;
  18. }
  19. }
  20. } if (n==1 and a==1 and b==1) cout << 1;
  21. else cout << 0;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement