Submission #73510

# Submission time Handle Problem Language Result Execution time Memory
73510 2018-08-28T11:16:17 Z yusufake parentrises (BOI18_parentrises) C++
50 / 100
29 ms 11120 KB
#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

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 496 KB Output is correct
3 Correct 3 ms 552 KB Output is correct
4 Correct 3 ms 552 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 644 KB Output is correct
2 Correct 3 ms 648 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 3 ms 656 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 644 KB Output is correct
2 Correct 3 ms 648 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 3 ms 656 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
6 Correct 2 ms 684 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 728 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 644 KB Output is correct
2 Correct 3 ms 648 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 3 ms 656 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
6 Correct 2 ms 684 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 728 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
11 Correct 4 ms 736 KB Output is correct
12 Correct 5 ms 784 KB Output is correct
13 Correct 3 ms 828 KB Output is correct
14 Correct 3 ms 844 KB Output is correct
15 Correct 3 ms 876 KB Output is correct
16 Correct 5 ms 1012 KB Output is correct
17 Correct 5 ms 1508 KB Output is correct
18 Correct 5 ms 1508 KB Output is correct
19 Correct 5 ms 1508 KB Output is correct
20 Correct 6 ms 1808 KB Output is correct
21 Correct 29 ms 3056 KB Output is correct
22 Correct 25 ms 8180 KB Output is correct
23 Correct 15 ms 8180 KB Output is correct
24 Correct 21 ms 8180 KB Output is correct
25 Correct 26 ms 11120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11120 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11120 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11120 KB Unexpected end of file - int32 expected