Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- freopen("input.txt" , "r" , stdin);
- freopen("output.txt" , "w" , stdout);
- string s;
- while (cin >> s) {
- stack <char> st;
- for (int i = 0; i < s.size(); i++) {
- if (s[i] == '{' || s[i] == '[' || s[i] == '(') {
- st.push(s[i]);
- }
- else
- if ((s[i] == '}' && st.top() == '{') || (s[i] == ']' && st.top() == '[') || (s[i] == ')' && st.top() == '(')) {
- st.pop();
- }
- else
- st.push(s[i]);
- }
- if (st.empty()) {
- cout << 0;
- } else {
- cout << 1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement