# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52812 | 2018-06-26T23:22:01 Z | ainta(#1378) | Match (CEOI16_match) | C++11 | 2000 ms | 1204 KB |
#include<cstdio> #include<algorithm> #define N_ 101000 using namespace std; char p[N_], st[N_], r[N_]; int n; bool Pos(int pv) { int i, top = 0; for (i = 1; i <= pv; i++) { if (r[i] == '(')st[++top] = p[i]; else { if (top && st[top] == p[i])top--; else return false; } } for (i = pv + 1; i <= n; i++) { if (top && st[top] == p[i])top--; else st[++top] = p[i]; } if (!top)return true; return false; } int main() { int i; scanf("%s", p + 1); for (i = 1; p[i]; i++); n = i - 1; if (!Pos(0)) { puts("-1"); return 0; } for (i = 1; i <= n; i++) { r[i] = '('; if (!Pos(i)) { r[i] = ')'; } } printf("%s\n", r + 1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 360 KB | Output is correct |
4 | Correct | 4 ms | 476 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 6 ms | 592 KB | Output is correct |
7 | Correct | 11 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 360 KB | Output is correct |
4 | Correct | 4 ms | 476 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 6 ms | 592 KB | Output is correct |
7 | Correct | 11 ms | 592 KB | Output is correct |
8 | Correct | 175 ms | 660 KB | Output is correct |
9 | Correct | 164 ms | 748 KB | Output is correct |
10 | Correct | 120 ms | 908 KB | Output is correct |
11 | Correct | 99 ms | 908 KB | Output is correct |
12 | Execution timed out | 2059 ms | 1204 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |