Submission #91018

#TimeUsernameProblemLanguageResultExecution timeMemory
91018choikiwonparentrises (BOI18_parentrises)C++17
0 / 100
2 ms720 KiB
#include<bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MN = 333; string S, ans; set<int> R[2], B[2], G[2]; void main2() { cin >> S; for(int i = 0; i < 2; i++) { R[i].clear(); B[i].clear(); G[i].clear(); } int rg = 0; int bg = 0; for(int i = 0; i < S.size(); i++) { if(S[i] == '(') { rg++; R[1].insert(i); } else { if(rg) { rg--; R[0].insert(i); } else if(bg) { bg--; B[0].insert(i); } else { B[0].insert(i); if(R[1].size()) { int t = *R[1].begin(); R[1].erase(t); G[1].insert(t); } else { cout << "impossible\n"; return; } } } } while(rg) { if(R[1].size() == 0) { cout << "impossible\n"; return; } int t = *R[1].rbegin(); R[1].erase(t); rg--; B[1].insert(t); bg++; } while(bg) { if(R[0].size()) { int t = *R[0].rbegin(); R[0].erase(t); G[0].insert(t); bg--; } else { cout << "impossible\n"; return; } } ans.clear(); ans.resize(S.size()); for(int i = 0; i < 2; i++) { for(auto it = R[i].begin(); it != R[i].end(); it++) { ans[*it] = 'R'; } for(auto it = B[i].begin(); it != B[i].end(); it++) { ans[*it] = 'B'; } for(auto it = G[i].begin(); it != G[i].end(); it++) { ans[*it] = 'G'; } } cout << ans << endl; } void main3() { } int P, TC; int main() { std::ios::sync_with_stdio(false); cin >> P >> TC; if(P == 1) { while(TC--) main2(); } if(P == 2) { while(TC--) main3(); } }

Compilation message (stderr)

parentrises.cpp: In function 'void main2()':
parentrises.cpp:20:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < S.size(); i++) {
                    ~~^~~~~~~~~~
#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...