Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- main()
- {
- #ifdef _DEBUG
- //freopen("in.txt", "rt", stdin);
- #endif // _DEBUG
- ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
- string s;
- getline(cin, s);
- int t = 0;
- for (int i = 0; i < (int)s.size(); i++)
- {
- int pw;
- if (((int)s.size() - i) == 3)
- pw = 100;
- else if (((int)s.size() - i) == 2)
- pw = 10;
- else
- pw = 1;
- t += (int(s[i] - '0')) * pw;
- }
- for (int i = 0; i < t; i++)
- {
- getline(cin, s);
- stack<char> st;
- for (auto a : s)
- {
- if (st.empty() || st.top() != a)
- st.push(a);
- else
- st.pop();
- }
- if (!st.empty())
- printf("NO\n");
- else
- printf("YES\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement