# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68316 | 2018-08-16T16:18:09 Z | aome | parentrises (BOI18_parentrises) | C++17 | 174 ms | 13328 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 (st.size() || st2.size()) fail = 1; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 412 KB | Output is correct |
4 | Correct | 2 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 544 KB | Output is correct |
2 | Correct | 3 ms | 620 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 636 KB | Output is correct |
5 | Correct | 3 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 544 KB | Output is correct |
2 | Correct | 3 ms | 620 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 636 KB | Output is correct |
5 | Correct | 3 ms | 640 KB | Output is correct |
6 | Correct | 3 ms | 640 KB | Output is correct |
7 | Correct | 2 ms | 640 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 640 KB | Output is correct |
10 | Correct | 2 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 544 KB | Output is correct |
2 | Correct | 3 ms | 620 KB | Output is correct |
3 | Correct | 2 ms | 624 KB | Output is correct |
4 | Correct | 2 ms | 636 KB | Output is correct |
5 | Correct | 3 ms | 640 KB | Output is correct |
6 | Correct | 3 ms | 640 KB | Output is correct |
7 | Correct | 2 ms | 640 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 640 KB | Output is correct |
10 | Correct | 2 ms | 640 KB | Output is correct |
11 | Correct | 4 ms | 640 KB | Output is correct |
12 | Correct | 3 ms | 652 KB | Output is correct |
13 | Correct | 3 ms | 680 KB | Output is correct |
14 | Correct | 3 ms | 732 KB | Output is correct |
15 | Correct | 4 ms | 736 KB | Output is correct |
16 | Correct | 22 ms | 892 KB | Output is correct |
17 | Correct | 8 ms | 1556 KB | Output is correct |
18 | Correct | 7 ms | 1556 KB | Output is correct |
19 | Correct | 9 ms | 1568 KB | Output is correct |
20 | Correct | 9 ms | 2068 KB | Output is correct |
21 | Correct | 174 ms | 3064 KB | Output is correct |
22 | Correct | 68 ms | 10388 KB | Output is correct |
23 | Correct | 45 ms | 10388 KB | Output is correct |
24 | Correct | 53 ms | 10388 KB | Output is correct |
25 | Correct | 70 ms | 13328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 13328 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 13328 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 13328 KB | Unexpected end of file - int32 expected |