Submission #69981

#TimeUsernameProblemLanguageResultExecution timeMemory
69981baqargamparentrises (BOI18_parentrises)C++14
50 / 100
176 ms12264 KiB
#include<bits/stdc++.h> using namespace std; int n,m,k,l,i,j,a,b,bal,li,ri,res[1000005]; string s; vector<int>vl,vr; main(){ int p; cin>>p; if(p==1) { int t; cin>>t; while(t--){ cin>>s; n=s.size(); vl.clear(); vr.clear();bal=0;li=0;ri=0; for(i=0;i<n;i++)res[i]=0; for(i=0;i<n;i++){ if(s[i]=='(') vl.push_back(i),bal++; else vr.push_back(i),bal--; if(vr.size()>2*vl.size()) {cout<<"impossible"<<endl;break;} if(bal<0){res[vl[li]]=3;li++;res[vr[ri]]=1;ri++;res[vr[ri]]=2;ri++;bal++;} } if(vr.size()>2*vl.size()) continue; vl.clear(); vr.clear();bal=0;li=0;ri=0; for(i=n-1;i>=0;i--){ if(res[i]!=0) continue; if(s[i]==')') vl.push_back(i),bal++; else vr.push_back(i),bal--; if(vr.size()>2*vl.size()) {cout<<"impossible"<<endl;break;} if(bal<0) {res[vl[li]]=3;li++;res[vr[ri]]=2;ri++;res[vr[ri]]=1;ri++;bal++;} } if(vr.size()>2*vl.size()) continue; for(i=0;i<n;i++){ if(res[i]==0) cout<<"R"; if(res[i]==1) cout<<"R"; if(res[i]==2) cout<<"B"; if(res[i]==3) cout<<"G"; } cout<<endl; }} }

Compilation message (stderr)

parentrises.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#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...