# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127212 | 2019-07-09T06:45:59 Z | Plurm | Match (CEOI16_match) | C++11 | 2 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; char str[100005]; char ans[100005]; int prefh[100005]; bool recur(int l, int r){ if(r < l) return true; if((r - l) % 2 == 0) return false; int mx = -1; for(int i = l+1; i <= r; i++){ if((prefh[i] ^ prefh[l-1]) == 0 && str[i] == str[l]){ mx = i; } } if(mx == -1) return false; ans[l] = '('; ans[mx] = ')'; return recur(l+1, mx-1) && recur(mx+1, r); } int main(){ scanf("%s",str+1); int n = strlen(str+1); for(int i = 1; i <= n; i++){ prefh[i] = prefh[i-1] ^ (1 << (str[i] - 'a')); } if(recur(1, n)){ ans[n+1] = '\0'; printf("%s",ans+1); }else{ printf("-1"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |