| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 244728 | evpipis | Match (CEOI16_match) | C++11 | 2067 ms | 880 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int len = 1e5+5;
char str[len], out[len];
stack<char> main_stack;
int n;
bool check(int i){
stack<char> sec_stack(main_stack);
sec_stack.push(str[i++]);
while (i < n){
if (sec_stack.empty() || sec_stack.top() != str[i])
sec_stack.push(str[i]);
else
sec_stack.pop();
i++;
}
return sec_stack.empty();
}
int main(){
scanf("%s", str);
n = strlen(str);
int ans = 1;
for (int i = 0; i < n; i++){
int test = check(i);
if (!test && main_stack.empty()){
ans = 0;
break;
}
//printf("i = %d, test = %d\n", i, test);
if (test)
main_stack.push(str[i]), out[i] = '(';
else
main_stack.pop(), out[i] = ')';
}
if (!ans){
printf("-1\n");
return 0;
}
for (int i = 0; i < n; i++)
printf("%c", out[i]);
printf("\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
