Advertisement
Zuneve

sec cpp

Aug 28th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 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. cin >> s;
  8. while (cin >> s) {
  9. for (auto c : s) {
  10. if (c == '(') n++;
  11. else if (c == ')') n--;
  12. else if (c == '[') a++;
  13. else if (c == ']') a--;
  14. else if (c == '{') b++;
  15. else b--;
  16. if (a<0 or b<0 or n<0) {
  17. cout << 0;
  18. break;
  19. }
  20. }
  21. } if (n==1 and a==1 and b==1) cout << 1;
  22. else cout << 0;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement