Submission #68313

#TimeUsernameProblemLanguageResultExecution timeMemory
68313aomeparentrises (BOI18_parentrises)C++17
11 / 100
3 ms740 KiB
#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(); } fail |= st.size() != 0; 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 (stderr)

parentrises.cpp: In function 'void Task1::solve()':
parentrises.cpp:16:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < s.size(); ++i) {
                    ~~^~~~~~~~~~
parentrises.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); ++i) cout << color[i]; cout << '\n';
                     ~~^~~~~~~~~~
parentrises.cpp:35:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 0; i < s.size(); ++i) cout << color[i]; cout << '\n';
     ^~~
parentrises.cpp:35:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (int i = 0; i < s.size(); ++i) cout << color[i]; cout << '\n';
                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...