# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73510 | yusufake | parentrises (BOI18_parentrises) | C++98 | 29 ms | 11120 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define _ int v, int tl, int tr, int l, int r
#define tm (tl+tr >> 1)
#define sol v+v,tl,tm,l,r
#define sag v+v+1,tm+1,tr,l,r
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pp pair<int,int>
const int N = 1e6 + 6;
int V[N],v,zz,ww,n,i,p,ok;
char s[N],ans[N];
int main(){
scanf("%d%d",&zz,&ww);
if(zz == 2) return 0;
for(;ww--;){
scanf(" %s",s+1);
n = strlen(s+1);
p = v = 0;
ok = 1;
for(i=1;i<=n;i++) ans[i] = 'G';
ans[n+1] = 0;
for(i=1;i<=n;i++){
p += s[i] == ')' ? 1 : -1;
if(s[i] == ')') V[++v] = i;
if(p > 0){
ans[ V[v--] ] = 'B';
ans[ V[v--] ] = 'R';
p = 0;
if(v == -1) { ok=0; break; }
}
}
p = v = 0;
for(i=n; i ;i--){
p += s[i] == '(' ? 1 : -1;
if(s[i] == '(') V[++v] = i;
if(p > 0){
ans[ V[v--] ] = 'B';
ans[ V[v--] ] = 'R';
p = 0;
if(v == -1) { ok=0; break; }
}
}
puts(ok ? ans+1 : "impossible");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |