# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
248667 | 2020-07-13T03:07:56 Z | thebes | parentrises (BOI18_parentrises) | C++14 | 206 ms | 9320 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 1e6+6, MM = 303; int S, T, N, i, j, w[MN], cur, fl; string s; stack<int> go; int main(){ scanf("%d",&S); if(S==1){ scanf("%d",&T); while(T--){ cin >> s; N = (int)s.size(); for(i=0;i<N;i++) w[i]=1; while(go.size()) go.pop(); cur = fl = 0; for(i=0;i<N;i++){ if(s[i]=='('){ cur++; go.push(i); } else if(cur) cur--; else{ if(go.empty()){ fl=1; break; } w[go.top()]=2; go.pop(); } } while(go.size()) go.pop(); cur = 0; for(i=N-1;i>=0;i--){ if(s[i]==')'){ cur++; go.push(i); } else if(cur>=w[i]) cur-=w[i]; else{ int r = cur; cur = 0; while(r<w[i]){ if(go.empty()){ fl=1; break; } r++; w[go.top()]=2; go.pop(); } } } if(fl) printf("impossible\n"); else{ int hm[]={0,0}; for(i=0;i<N;i++){ if(w[i]==2) printf("G"); else{ int idx=s[i]=='('?0:1; printf("%c","BR"[hm[idx]]), hm[idx]=!hm[idx]; } } printf("\n"); } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 24 ms | 512 KB | Output is correct |
17 | Correct | 12 ms | 1280 KB | Output is correct |
18 | Correct | 10 ms | 640 KB | Output is correct |
19 | Correct | 11 ms | 896 KB | Output is correct |
20 | Correct | 12 ms | 1280 KB | Output is correct |
21 | Correct | 206 ms | 2176 KB | Output is correct |
22 | Correct | 119 ms | 9280 KB | Output is correct |
23 | Correct | 111 ms | 2744 KB | Output is correct |
24 | Correct | 103 ms | 5580 KB | Output is correct |
25 | Correct | 112 ms | 9320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 256 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 256 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 256 KB | Unexpected end of file - int32 expected |