Advertisement
stas224

Untitled

Oct 11th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. int main()
  6. {
  7. string s;
  8. cin >> s;
  9. vector<char>n;
  10. int k = s.size()
  11. for (int i = 0;i < k; i++){
  12. if (s[i] == '('){
  13. n.push_back(s[i]);
  14. }
  15. if (s[i] == '[') {
  16. n.push_back(s[i]);
  17. }
  18. if (s[i] == '{'){
  19. n.push_back(s[i]);
  20. }
  21.  
  22. if ( s[i] == ')' && n[n.size()-1] == '('){
  23. n.pop_back();
  24. }
  25. if ( s[i] == ']' && n[n.size()-1] == '['){
  26. n.pop_back();
  27. }
  28.  
  29. if ( s[i] == '}' && n[n.size()-1] == '{'){
  30. n.pop_back();
  31. }
  32. }
  33. if (int t = n.size() > 0){
  34. cout << "NO";
  35. }
  36. else {
  37. cout << "YES";
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement