# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862040 | 2023-10-17T12:19:16 Z | Aiperiii | parentrises (BOI18_parentrises) | C++14 | 130 ms | 5192 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(),x.end() #define ff first #define ss second signed main(){ int p,t; cin>>p>>t; if(p==1){ while(t--){ string s,x=""; cin>>s; stack <int> st; for(int i=0;i<s.size();i++){ x+='.'; } for(int i=0;i<s.size();i++){ if(s[i]=='(')st.push(i); else{ if(st.size()!=0){ x[st.top()]='R'; x[i]='R'; st.pop(); } } } while(st.size()!=0)st.pop(); for(int i=0;i<s.size();i++){ if(s[i]=='(' && x[i]=='.')st.push(i); else if(s[i]==')'){ if(st.size()!=0){ x[st.top()]='B'; x[i]='G'; st.pop(); } } } while(st.size()!=0)st.pop(); for(int i=s.size()-1;i>=0;i--){ if(s[i]==')' && x[i]=='.')st.push(i); else if(s[i]=='(' && x[i]=='R'){ if(st.size()!=0){ x[st.top()]='B'; x[i]='G'; st.pop(); } } } bool flag=true; for(int i=0;i<x.size();i++){ if(x[i]=='.')flag=false; } if(flag)cout<<x<<"\n"; else cout<<"impossible\n"; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 412 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 444 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 15 ms | 588 KB | Output is correct |
17 | Correct | 4 ms | 860 KB | Output is correct |
18 | Correct | 4 ms | 604 KB | Output is correct |
19 | Correct | 4 ms | 604 KB | Output is correct |
20 | Correct | 4 ms | 860 KB | Output is correct |
21 | Correct | 130 ms | 2436 KB | Output is correct |
22 | Correct | 38 ms | 5192 KB | Output is correct |
23 | Correct | 33 ms | 2488 KB | Output is correct |
24 | Correct | 36 ms | 3108 KB | Output is correct |
25 | Correct | 37 ms | 5192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |