# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42436 | 2018-02-27T07:29:17 Z | nonocut | Match (CEOI16_match) | C++14 | 226 ms | 282336 KB |
#include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; char s[maxn], a[maxn], ans[maxn]; set<int> pos[30][maxn]; void solve(int l, int r, int cur) { if(l>r) return ; int x = *(--pos[s[l]-'a'][cur].upper_bound(r)); ans[l] = '('; ans[x] = ')'; solve(l+1,x-1,cur+1); solve(x+1,r,cur); } int main() { scanf(" %s",s); n = strlen(s); int r = 0; for(int i=n-1;i>=0;i--) { pos[s[i]-'a'][r].insert(i); a[++r] = s[i]; while(r>=2 && a[r]==a[r-1]) r-=2; } if(r>0) return !printf("-1"); solve(0,n-1,0); printf("%s",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 113 ms | 141320 KB | Output is correct |
2 | Runtime error | 226 ms | 282336 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 113 ms | 141320 KB | Output is correct |
2 | Runtime error | 226 ms | 282336 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 113 ms | 141320 KB | Output is correct |
2 | Runtime error | 226 ms | 282336 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |