# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52916 | 2018-06-27T07:21:18 Z | 김세빈(#1383) | Match (CEOI16_match) | C++11 | 2000 ms | 884 KB |
#include <bits/stdc++.h> using namespace std; char str[101010], ans[101010]; vector <char> V; int n; bool check(int p) { int i; V.clear(); for(i=0;i<=p;i++){ if(ans[i] == '(') V.push_back(str[i]); else V.pop_back(); } for(;i<n;i++){ if(V.empty() || V.back() != str[i]) V.push_back(str[i]); else V.pop_back(); } return V.empty(); } int main() { int i; scanf("%s",str); for(n=0;str[n];n++); // if(n > 2000) return 0; ans[0] = '('; if(!check(0)){ printf("-1\n"); return 0; } for(i=0;i<n;i++){ ans[i] = '('; if(!check(i)) ans[i] = ')'; } ans[n] = '\0'; printf("%s\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 3 ms | 484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 3 ms | 484 KB | Output is correct |
4 | Correct | 4 ms | 484 KB | Output is correct |
5 | Correct | 6 ms | 664 KB | Output is correct |
6 | Correct | 8 ms | 664 KB | Output is correct |
7 | Correct | 10 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 3 ms | 484 KB | Output is correct |
4 | Correct | 4 ms | 484 KB | Output is correct |
5 | Correct | 6 ms | 664 KB | Output is correct |
6 | Correct | 8 ms | 664 KB | Output is correct |
7 | Correct | 10 ms | 664 KB | Output is correct |
8 | Correct | 152 ms | 664 KB | Output is correct |
9 | Correct | 162 ms | 688 KB | Output is correct |
10 | Correct | 115 ms | 736 KB | Output is correct |
11 | Correct | 115 ms | 736 KB | Output is correct |
12 | Execution timed out | 2068 ms | 884 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |