# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61873 | 2018-07-27T03:50:30 Z | ainta(#1792) | parentrises (BOI18_parentrises) | C++11 | 3 ms | 480 KB |
#include<cstdio> #include<algorithm> #define N_ 1010000 using namespace std; char p[N_]; int n, S[N_], v[N_][2]; void Do(int ck) { int i; S[0] = 0; for (i = 0; i < n; i++) { if (p[i] == '(')S[i + 1] = S[i] + 1; else S[i + 1] = S[i] - 1; } int Mn = 0; for (i = 1; i <= n; i++) { if (Mn > S[i]) { Mn = S[i]; v[i - 1][ck] = 1; } } int t = S[n] - Mn; for (i = n - 1; i >= 0 && t; i--) { if (p[i] == '(') { t--; v[i][ck] = 1; } } } void Solve1() { int TC, i; scanf("%d", &TC); while (TC--) { scanf("%s", p); for (i = 0; p[i]; i++)v[i][0] = v[i][1] = 0; n = i; Do(0); reverse(p, p + n); for (i = 0; i < n; i++)p[i] = '(' + ')' - p[i]; Do(1); for (i = 0; i < n; i++) { if (v[i][0] && v[n - i - 1][1]) { puts("impossible"); break; } } if (i == n) { for (i = 0; i < n; i++) { if (v[i][0])printf("B"); else if (v[n - i - 1][1])printf("R"); else printf("G"); } puts(""); } } } void Solve2() { } int main() { //freopen("input.txt", "r", stdin); int ck; scanf("%d", &ck); if (ck == 1) { Solve1(); } else { Solve2(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 356 KB | Output is correct |
2 | Incorrect | 2 ms | 432 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 356 KB | Output is correct |
2 | Incorrect | 2 ms | 432 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 356 KB | Output is correct |
2 | Incorrect | 2 ms | 432 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 480 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 480 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 480 KB | Unexpected end of file - int32 expected |