Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- string s;
- cin >> s;
- vector<char>n;
- int k = s.size()
- for (int i = 0;i < k; i++){
- if (s[i] == '('){
- n.push_back(s[i]);
- }
- if (s[i] == '[') {
- n.push_back(s[i]);
- }
- if (s[i] == '{'){
- n.push_back(s[i]);
- }
- if ( s[i] == ')' && n[n.size()-1] == '('){
- n.pop_back();
- }
- if ( s[i] == ']' && n[n.size()-1] == '['){
- n.pop_back();
- }
- if ( s[i] == '}' && n[n.size()-1] == '{'){
- n.pop_back();
- }
- }
- if (int t = n.size() > 0){
- cout << "NO";
- }
- else {
- cout << "YES";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement