# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70005 | 2018-08-22T08:54:08 Z | octopuses | parentrises (BOI18_parentrises) | C++17 | 62 ms | 9532 KB |
//Giorgi Kldiashvili #include <bits/stdc++.h> #define ll long long #define fr first #define sc second #define M 1000000007 using namespace std; const int N = 1000020; int n, k; int used[N]; bool f[N]; char ch[N]; void go1() { vector < int > c; c.clear(); scanf("%s", &ch); n = strlen(ch); int A, B; A = B = 0; for(int i = 0; i < n; ++ i) { if(ch[i] == '(') A ++; if(ch[i] == ')') B ++; if(B > A * 2) { printf("impossible\n"); return; } } A = B = 0; for(int i = n - 1; i >= 0; -- i) { if(ch[i] == ')') A ++; if(ch[i] == '(') B ++; if(B > A * 2) { printf("impossible\n"); return; } } for(int i = 0; i < n; ++ i) used[i] = 0, f[i] = 0; int now = 1; for(int i = 1; i < n; ++ i) { if(ch[i] == ')') c.push_back(i); now += (ch[i] == ')')?-1:1; if(now < 0) { used[c.back()] = 1; c.pop_back(); used[c.back()] = 2; c.pop_back(); now = 0; } } now = 1; c.clear(); if(used[n - 1] == 2) now = 0; for(int i = n - 2; i >= 0; -- i) { if(used[i] == 2) continue; if(ch[i] == '(') c.push_back(i); now += (ch[i] == '(')?-1:1; if(now < 0) { used[c.back()] = 1; c.pop_back(); used[c.back()] = 2; c.pop_back(); now = 0; } } for(int i = 0; i < n; ++ i) { if(used[i] == 0) putchar('G'); if(used[i] == 1) putchar('R'); if(used[i] == 2) putchar('B'); } printf("\n"); } int A[305][305][305]; void go2() { A[0][0][0] = 1; } int sub, T; int main() { scanf("%d", &sub); scanf("%d\n", &T); if(sub == 1) { while(T --) go1(); } else { go2(); while(T --) { scanf("%d", &n); printf("%d\n", A[n][0][0]); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 456 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 | 552 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 552 KB | Output is correct |
2 | Correct | 3 ms | 552 KB | Output is correct |
3 | Correct | 2 ms | 664 KB | Output is correct |
4 | Correct | 2 ms | 664 KB | Output is correct |
5 | Correct | 2 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 552 KB | Output is correct |
2 | Correct | 3 ms | 552 KB | Output is correct |
3 | Correct | 2 ms | 664 KB | Output is correct |
4 | Correct | 2 ms | 664 KB | Output is correct |
5 | Correct | 2 ms | 664 KB | Output is correct |
6 | Correct | 2 ms | 664 KB | Output is correct |
7 | Correct | 3 ms | 664 KB | Output is correct |
8 | Correct | 2 ms | 664 KB | Output is correct |
9 | Correct | 3 ms | 664 KB | Output is correct |
10 | Correct | 2 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 552 KB | Output is correct |
2 | Correct | 3 ms | 552 KB | Output is correct |
3 | Correct | 2 ms | 664 KB | Output is correct |
4 | Correct | 2 ms | 664 KB | Output is correct |
5 | Correct | 2 ms | 664 KB | Output is correct |
6 | Correct | 2 ms | 664 KB | Output is correct |
7 | Correct | 3 ms | 664 KB | Output is correct |
8 | Correct | 2 ms | 664 KB | Output is correct |
9 | Correct | 3 ms | 664 KB | Output is correct |
10 | Correct | 2 ms | 664 KB | Output is correct |
11 | Correct | 3 ms | 664 KB | Output is correct |
12 | Correct | 3 ms | 748 KB | Output is correct |
13 | Correct | 4 ms | 748 KB | Output is correct |
14 | Correct | 3 ms | 748 KB | Output is correct |
15 | Correct | 3 ms | 764 KB | Output is correct |
16 | Correct | 5 ms | 876 KB | Output is correct |
17 | Correct | 9 ms | 1704 KB | Output is correct |
18 | Correct | 6 ms | 1704 KB | Output is correct |
19 | Correct | 6 ms | 1704 KB | Output is correct |
20 | Correct | 10 ms | 1704 KB | Output is correct |
21 | Correct | 31 ms | 1704 KB | Output is correct |
22 | Correct | 62 ms | 9532 KB | Output is correct |
23 | Correct | 36 ms | 9532 KB | Output is correct |
24 | Correct | 59 ms | 9532 KB | Output is correct |
25 | Correct | 58 ms | 9532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 9532 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 9532 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 9532 KB | Output isn't correct |