# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
134143 |
2019-07-22T06:57:34 Z |
임유진(#3231) |
괄호 문자열 (CEOI16_match) |
C++14 |
|
93 ms |
504 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20;
int N;
char s[MAXN];
int main() {
cin >> s;
for(N = 0; s[N]; N++);
//printf("N = %d\n", N);
for(int i = 0; i < (1 << N); i++) {
//printf("i = %d\n", i);
stack<char> st;
bool b = true;
for(int j = 0; j < N; j++) {
if(i & (1 << (N - j - 1))) {
if(st.empty() || st.top() != s[j]) {
b = false;
break;
}
st.pop();
}
else st.push(s[j]);
}
if(st.empty() && b) {
for(int j = 0; j < N; j++) cout << ((i & (1 << (N - j - 1))) ? ')' : '(');
return 0;
}
}
cout << -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
276 KB |
Output is correct |
3 |
Correct |
8 ms |
252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
276 KB |
Output is correct |
3 |
Correct |
8 ms |
252 KB |
Output is correct |
4 |
Runtime error |
93 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
276 KB |
Output is correct |
3 |
Correct |
8 ms |
252 KB |
Output is correct |
4 |
Runtime error |
93 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |