# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53497 | 2018-06-30T06:26:32 Z | baactree | Match (CEOI16_match) | C++17 | 3 ms | 624 KB |
#include <bits/stdc++.h> using namespace std; int n; char str[100005]; int sum[100005]; bool possi[100005]; bool solve(int le, int ri) { if (le > ri)return true; stack<int> st; for (int i = le; i <= ri; i++) { if (!st.empty() && st.top() == str[i])st.pop(); else st.push(str[i]); possi[i] = st.empty(); } for (int i = ri; i > le; i--) { if (str[i] == str[le] && possi[ri]) { str[le] = '('; str[i] = ')'; return solve(le + 1, i - 1) && solve(i + 1, ri); } } return false; } int main() { scanf("%s", str + 1); n = strlen(str + 1); for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] ^ (1 << (str[i] - 'a')); if(solve(1, n)) printf("%s\n", str + 1); else printf("-1\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 560 KB | Output is correct |
4 | Incorrect | 3 ms | 624 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 560 KB | Output is correct |
4 | Incorrect | 3 ms | 624 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |