Submission #861790

#TimeUsernameProblemLanguageResultExecution timeMemory
861790maks007parentrises (BOI18_parentrises)C++14
5 / 100
1055 ms428 KiB
#include "bits/stdc++.h" using namespace std; string str; vector <int> rgb, ans; int f; void do_1() { if(rgb.size() == str.size()) { int balb = 0, balr = 0; for(int i = 0; i < str.size(); i ++) { if(str[i] == '(') { if(rgb[i] == 0) balb ++; else if(rgb[i] == 1) balr ++; else balb ++, balr ++; }else { if(rgb[i] == 0) balb --; else if(rgb[i] == 1) balr --; else balb --, balr --; if(min(balb, balr) < 0) goto end; } } if(balr == 0 && balb == 0) { ans = rgb; f = 1; } return; end:; return; } for(int i = 0; i < 3; i ++) { rgb.push_back(i); do_1(); rgb.pop_back(); if(f) return; } } signed main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T, q; cin >> T >> q; while(q --) { cin >> str; if(T == 1) { f = 0; do_1(); if(!f) { cout << "impossible\n"; continue; } for(auto i : ans) { if(i == 0) cout << "B"; else if(i == 1) cout << "R"; else cout << "G"; } cout << "\n"; }else { // cout << ans; } } return 0; }

Compilation message (stderr)

parentrises.cpp: In function 'void do_1()':
parentrises.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for(int i = 0; i < str.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...