# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
64198 | 2018-08-03T13:31:53 Z | Just_Solve_The_Problem | parentrises (BOI18_parentrises) | C++11 | 181 ms | 13456 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() const int N = (int)1e6 + 7; const int inf = (int)1e9 + 7; int b[N]; vector < int > stk; int a[N]; void solve1() { string s; cin >> s; b[0] = ((s[0] == '(') ? 1 : -1); a[0] = 1; for (int i = 1; i < sz(s); i++) { b[i] = b[i - 1] + ((s[i] == '(') ? 1 : -1); a[i] = 1; } int cur = 0; stk.clear(); for (int i = 0; i < sz(s); i++) { if (s[i] == ')') stk.pb(i); if (b[i] + cur < 0) { // cout << i << ' ' << b[i] + cur << ' ' << sz(stk) << endl; while (b[i] + cur < 0 && sz(stk) > 1) { a[stk.back()] = 0; stk.pop_back(); a[stk.back()] = 2; stk.pop_back(); cur++; } if (b[i] + cur < 0) { puts("impossible"); return ; } } } stk.clear(); for (int i = 0; i < sz(s); i++) { if (s[i] == '(') stk.pb(i); } int b1 = b[sz(s) - 1] + cur; while (b1 > 0 && sz(stk) > 1) { b1--; a[stk.back()] = 0; stk.pop_back(); a[stk.back()] = 2; stk.pop_back(); } if (b1 > 0) { puts("impossible"); return ; } b1 = 0; int b2 = 0; bool fl = 0; for (int i = 0; i < sz(s); i++) { if (a[i] <= 1) { b1 += ((s[i] == '(') ? 1 : -1); } if (a[i] >= 1) { b2 += ((s[i] == '(') ? 1 : -1); } fl |= (b1 < 0 || b2 < 0); } fl |= (b1 != 0 || b2 != 0); if (fl) { puts("impossible"); return ; } for (int i = 0; i < sz(s); i++) { if (a[i] == 0) printf("R"); else if (a[i] == 1) printf("G"); else printf("B"); } puts(""); } void solve2() { int n; scanf("%d", &n); } main() { int p; scanf("%d", &p); int test; scanf("%d", &test); if (p == 1) { while (test--) solve1(); } else { while (test--) solve2(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 3 ms | 432 KB | Output is correct |
4 | Correct | 3 ms | 480 KB | Output is correct |
5 | Correct | 3 ms | 480 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 684 KB | Output is correct |
2 | Correct | 3 ms | 684 KB | Output is correct |
3 | Correct | 3 ms | 684 KB | Output is correct |
4 | Correct | 3 ms | 684 KB | Output is correct |
5 | Correct | 2 ms | 684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 684 KB | Output is correct |
2 | Correct | 3 ms | 684 KB | Output is correct |
3 | Correct | 3 ms | 684 KB | Output is correct |
4 | Correct | 3 ms | 684 KB | Output is correct |
5 | Correct | 2 ms | 684 KB | Output is correct |
6 | Correct | 3 ms | 684 KB | Output is correct |
7 | Correct | 2 ms | 684 KB | Output is correct |
8 | Correct | 4 ms | 684 KB | Output is correct |
9 | Correct | 3 ms | 684 KB | Output is correct |
10 | Correct | 2 ms | 684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 684 KB | Output is correct |
2 | Correct | 3 ms | 684 KB | Output is correct |
3 | Correct | 3 ms | 684 KB | Output is correct |
4 | Correct | 3 ms | 684 KB | Output is correct |
5 | Correct | 2 ms | 684 KB | Output is correct |
6 | Correct | 3 ms | 684 KB | Output is correct |
7 | Correct | 2 ms | 684 KB | Output is correct |
8 | Correct | 4 ms | 684 KB | Output is correct |
9 | Correct | 3 ms | 684 KB | Output is correct |
10 | Correct | 2 ms | 684 KB | Output is correct |
11 | Correct | 5 ms | 684 KB | Output is correct |
12 | Correct | 5 ms | 748 KB | Output is correct |
13 | Correct | 5 ms | 748 KB | Output is correct |
14 | Correct | 5 ms | 748 KB | Output is correct |
15 | Correct | 3 ms | 796 KB | Output is correct |
16 | Correct | 22 ms | 796 KB | Output is correct |
17 | Correct | 21 ms | 1948 KB | Output is correct |
18 | Correct | 15 ms | 1948 KB | Output is correct |
19 | Correct | 16 ms | 1948 KB | Output is correct |
20 | Correct | 22 ms | 1948 KB | Output is correct |
21 | Correct | 174 ms | 1948 KB | Output is correct |
22 | Correct | 181 ms | 13456 KB | Output is correct |
23 | Correct | 83 ms | 13456 KB | Output is correct |
24 | Correct | 126 ms | 13456 KB | Output is correct |
25 | Correct | 129 ms | 13456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 13456 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 13456 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 13456 KB | Unexpected end of file - int32 expected |