# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
231356 | 2020-05-13T12:27:54 Z | nicolaalexandra | 괄호 문자열 (CEOI16_match) | C++14 | 2000 ms | 504 KB |
#include <bits/stdc++.h> #define DIM 100010 using namespace std; char v[DIM]; deque <char> s,d; int n,i; int verif (int poz){ for (int i=poz;i<=n;i++){ if (!d.empty() && d.back() == v[i]) d.pop_back(); else d.push_back(v[i]); } return d.empty(); } int main (){ //ifstream cin ("match.in"); //ofstream cout ("match.out"); cin>>v+1; n = strlen (v+1); /// verific daca am solutie s.push_back(v[1]); for (i=2;i<=n;i++){ if (!s.empty() && s.back() == v[i]) s.pop_back(); else s.push_back(v[i]); } if (!s.empty()){ cout<<-1; return 0; } s.push_back(v[1]); cout<<"("; for (i=2;i<=n;i++){ /// incerc sa pun ( d = s; d.push_back(v[i]); if (verif(i+1)){ s.push_back(v[i]); cout<<"("; } else { cout<<")"; s.pop_back(); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 8 ms | 256 KB | Output is correct |
5 | Correct | 7 ms | 384 KB | Output is correct |
6 | Correct | 10 ms | 384 KB | Output is correct |
7 | Correct | 15 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 8 ms | 256 KB | Output is correct |
5 | Correct | 7 ms | 384 KB | Output is correct |
6 | Correct | 10 ms | 384 KB | Output is correct |
7 | Correct | 15 ms | 384 KB | Output is correct |
8 | Correct | 125 ms | 388 KB | Output is correct |
9 | Correct | 140 ms | 392 KB | Output is correct |
10 | Correct | 126 ms | 480 KB | Output is correct |
11 | Correct | 105 ms | 384 KB | Output is correct |
12 | Execution timed out | 2099 ms | 504 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |