# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68315 | 2018-08-16T16:00:21 Z | aome | parentrises (BOI18_parentrises) | C++17 | 3 ms | 648 KB |
#include <bits/stdc++.h> using namespace std; namespace Task1 { char color[1000005]; void solve() { int q; cin >> q; while (q--) { string s; cin >> s; stack<int> st; stack<int> st2; stack<int> st3; bool fail = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] == '(') st.push(i), color[i] = 'G'; else { if (st.size()) { st2.push(i), color[i] = 'G', st3.push(st.top()), st.pop(); } else { if (!st2.size()) { fail = 1; break; } color[i] = 'R', color[st2.top()] = 'B', st2.pop(), st3.pop(); } } } while (st.size() && st3.size()) { color[st.top()] = 'R', color[st3.top()] = 'B'; st.pop(), st3.pop(); } while (st.size()) st.pop(); while (st2.size()) st2.pop(); for (int i = 0; i < s.size(); ++i) { if (s[i] == '(') { if (color[i] == 'G' || color[i] == 'R') st.push(i); if (color[i] == 'G' || color[i] == 'B') st2.push(i); } else { if (color[i] == 'G' || color[i] == 'R') { if (!st.size()) { fail = 1; break; } st.pop(); } if (color[i] == 'G' || color[i] == 'B') { if (!st2.size()) { fail = 1; break; } st2.pop(); } } } if (fail) cout << "impossible\n"; else { for (int i = 0; i < s.size(); ++i) cout << color[i]; cout << '\n'; } } } } namespace Task2 { void solve() { } } int main() { ios::sync_with_stdio(false); int P; cin >> P; if (P == 1) Task1::solve(); else Task2::solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Incorrect | 3 ms | 504 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 568 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 3 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 568 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 3 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 3 ms | 592 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Incorrect | 3 ms | 644 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 568 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 3 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 3 ms | 592 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Incorrect | 3 ms | 644 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 648 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 648 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 648 KB | Unexpected end of file - int32 expected |