# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
809092 | 2023-08-05T16:54:09 Z | nonono | 괄호 문자열 (CEOI16_match) | C++14 | 8 ms | 340 KB |
#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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 212 KB | Output is correct |
6 | Correct | 5 ms | 340 KB | Output is correct |
7 | Correct | 8 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 3 ms | 340 KB | Output is correct |
5 | Correct | 3 ms | 212 KB | Output is correct |
6 | Correct | 5 ms | 340 KB | Output is correct |
7 | Correct | 8 ms | 340 KB | Output is correct |
8 | Incorrect | 1 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |