# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115237 | 2019-06-06T08:26:14 Z | 김세빈(#2863) | Match (CEOI16_match) | C++14 | 2 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; char s[101010]; int dp[101010]; int n; void die() { printf("-1\n"); exit(0); } void make(int p) { int i; s[p] = '('; s[dp[p]] = ')'; for(i=p+1; i<dp[p]; i=dp[i]+1){ make(i); if(dp[i] >= dp[p]) die(); } } int main() { int i, j; scanf("%s", s); n = strlen(s); for(i=n-1; i>=0; i--){ dp[i] = n; for(j=i+1; j<n; j=dp[j]+1){ if(s[i] == s[j]) dp[i] = j; } } for(i=0; i<n; i=dp[i]+1){ make(i); if(dp[i] >= n) die(); } printf("%s\n", s); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |