# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61212 | 2018-07-25T11:25:57 Z | junodeveloper | 괄호 문자열 (CEOI16_match) | C++17 | 3 ms | 536 KB |
#include <bits/stdc++.h> using namespace std; char s[100010],a[100010]; int pre[100010][26]; void solve(int l, int r) { if(l > r) return; if(pre[r][s[l]-'a'] <= l) { puts("-1"); exit(0); } a[l] = '(', a[pre[r][s[l]-'a']] = ')'; solve(l+1, pre[r][s[l]-'a']-1), solve(pre[r][s[l]-'a']+1, r); } int main() { scanf("%s", s); int n = strlen(s); for(int i=0; i<n; i++) { for(int j=0; j<26; j++) if(j == s[i]-'a') pre[i][j] = i; else if(i && pre[i-1][s[i]-'a']) pre[i][j] = pre[pre[i-1][s[i]-'a']-1][j]; else pre[i][j] = -1; } solve(0,n-1); puts(a); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 496 KB | Output is correct |
3 | Runtime error | 3 ms | 536 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 496 KB | Output is correct |
3 | Runtime error | 3 ms | 536 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 496 KB | Output is correct |
3 | Runtime error | 3 ms | 536 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |