# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
809092 | nonono | 괄호 문자열 (CEOI16_match) | C++14 | 8 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5 + 10;
int n;
string s;
namespace sub {
int mark[mxN];
bool check() {
vector<int> q;
for(int i = 1; i <= n; i ++) {
if(mark[i]) {
q.push_back(i - 1);
continue ;
}
if(!q.empty() && s[q.back()] == s[i - 1]) q.pop_back();
else {
q.push_back(i - 1);
}
}
return q.size() == 0;
}
int main() {
for(int i = 1; i <= n; i ++) mark[i] = 0;
if(!check()) {
return cout << -1, 0;
}
for(int i = 1; i <= n; i ++) {
mark[i] = 1;
mark[i] = check();
}
for(int i = 1; i <= n; i ++) cout << (mark[i] ? '(' : ')');
return 0;
}
}
int main() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> s;
n = s.size();
if(n <= 2000) sub :: main();
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... |