# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42432 | 2018-02-27T06:43:06 Z | nonocut | 괄호 문자열 (CEOI16_match) | C++14 | 19 ms | 820 KB |
#include<bits/stdc++.h> using namespace std; #define pci pair<char,int> #define X first #define Y second const int maxn = 2e3 + 5; int n; char s[maxn]; int fix[maxn]; pci a[maxn]; bool check() { int r = 0; for(int i=0;i<n;i++) { a[++r] = {s[i],fix[i]}; while(r>=2 && a[r].X==a[r-1].X) { if(a[r].Y==0 || (a[r-1].Y==-1 && a[r].Y==1)) r-=2; else break; } } return (r==0); } int main() { scanf(" %s",s); n = strlen(s); for(int i=0;i<n;i++) { fix[i] = -1; if(!check()) fix[i] = 1; } if(check()) { for(int i=0;i<n;i++) printf("%c", (fix[i]==-1 ? '(' : ')')); } else printf("-1"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 5 ms | 572 KB | Output is correct |
5 | Correct | 5 ms | 576 KB | Output is correct |
6 | Correct | 17 ms | 684 KB | Output is correct |
7 | Correct | 19 ms | 688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 5 ms | 572 KB | Output is correct |
5 | Correct | 5 ms | 576 KB | Output is correct |
6 | Correct | 17 ms | 684 KB | Output is correct |
7 | Correct | 19 ms | 688 KB | Output is correct |
8 | Runtime error | 2 ms | 820 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Halted | 0 ms | 0 KB | - |