# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98573 | 2019-02-24T13:18:17 Z | tdwn | parentrises (BOI18_parentrises) | C++17 | 225 ms | 7400 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; string code; void solve() { cin>>code; string answ = code; stack<int>s1, s2; for(int i=0;i<code.length();i++) { if(code[i] == '(') { s1.push(i); } else { if(s1.size() > 0) { answ[s1.top()] = answ[i] = 'R'; s2.push(s1.top()); s1.pop(); } else if(s2.size() > 0) { answ[s2.top()] = 'G'; answ[i] = 'B'; s2.pop(); } else { cout<<"impossible\n"; return; } } } stack<int>t1, t2; for(int i=code.length()-1;i>=0;i--) { if(code[i] == ')') { t1.push(i); } else { if(answ[i] == 'R' || answ[i] == 'G') continue; else { if(t1.size() > 0) { answ[i] = 'B'; answ[t1.top()] = 'G'; t1.pop(); } else { cout<<"impossible\n"; return; } } } } cout<<answ<<"\n"; return; } int main() { int P, T; cin>>P; cin>>T; while(T--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 21 ms | 384 KB | Output is correct |
17 | Correct | 10 ms | 1024 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 8 ms | 736 KB | Output is correct |
20 | Correct | 8 ms | 1024 KB | Output is correct |
21 | Correct | 225 ms | 1144 KB | Output is correct |
22 | Correct | 57 ms | 7400 KB | Output is correct |
23 | Correct | 42 ms | 1672 KB | Output is correct |
24 | Correct | 47 ms | 3948 KB | Output is correct |
25 | Correct | 56 ms | 7400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Expected integer, but "impossible" found |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Expected integer, but "impossible" found |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Expected integer, but "impossible" found |