# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
134143 |
2019-07-22T06:57:34 Z |
임유진(#3231) |
Match (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;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |