Submission #73510

#TimeUsernameProblemLanguageResultExecution timeMemory
73510yusufakeparentrises (BOI18_parentrises)C++98
50 / 100
29 ms11120 KiB
#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)

parentrises.cpp: In function 'int main()':
parentrises.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&zz,&ww);
     ~~~~~^~~~~~~~~~~~~~~~
parentrises.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",s+1);
         ~~~~~^~~~~~~~~~~
#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...