# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67836 | 2018-08-15T10:50:44 Z | Good | parentrises (BOI18_parentrises) | C++11 | 3 ms | 700 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ff first #define ss second #define Maxn 1000009 #define ll long long #define pb push_back #define Inf 1000000009 #define ppb() pop_back() #define pii pair <int , int> #define mid(x, y) (x + y) / 2 #define all(x) x.begin(),x.end() #define llInf 1000000000000000009 #define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++) using namespace std; using namespace __gnu_pbds; typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order; int P, T; char s[Maxn]; int main () { //freopen ("file.in", "r", stdin); //freopen ("file.out", "w", stdout); //srand ((unsigned) time ( NULL )); //int randomNumber = rand() % 10 + 1; scanf ("%d%d", &P, &T); if (P == 1) { string s1; vector <pair <int, char> > v; for (int i = 1; i <= T; i++) { scanf ("%s", &s); v.clear (); s1 = s; int sz = strlen (s); for (int j = 0; j < sz; j++) s1[j] = '*'; for (int j = 0; j < sz; j++) { if (s[j] == '(') v.pb ({j, '('}); else { if (v.size() > 0 and v.back().ss == '(') s1[v.back().ff] = 'B', s1[j] = 'B', v.ppb (); else v.pb ({j, ')'}); } } for (auto j: v) { if (j.ss == '(') { for (int k = sz - 1; k > j.ff; k--) if (s[k] == ')' and s1[k] == 'B') { s1[k] = 'G', s1[j.ff] = 'R'; break; } } else { for (int k = j.ff - 1; k >= 0; k--) { if (s[k] == '(' and s1[k] == 'B') { s1[k] = 'G', s1[j.ff] = 'R'; break; } } } } bool d = 0; for (int j = 0; j < sz; j++) if (s1[j] == '*') { d = 1; break; } if (d) puts ("impossible"); else cout << s1 << '\n'; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Incorrect | 2 ms | 600 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 600 KB | Output is correct |
2 | Incorrect | 3 ms | 652 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 600 KB | Output is correct |
2 | Incorrect | 3 ms | 652 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 600 KB | Output is correct |
2 | Incorrect | 3 ms | 652 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 700 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 700 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 700 KB | Unexpected end of file - int32 expected |