# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038881 | 2024-07-30T08:38:56 Z | mar | parentrises (BOI18_parentrises) | C++14 | 109 ms | 5196 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ff first #define ss second signed main(){ int p,t; cin>>p>>t; if(p==1){ while(t--){ string s,ans=""; cin>>s; stack<int> st; for(int i=0; i<s.size(); i++){ ans+='.'; } for(int i=0; i<s.size(); i++){ if(s[i]=='(') { st.push(i); }else{ if(st.size()!=0){ ans[st.top()]='R'; ans[i]='R'; st.pop(); } } } while(st.size()!=0) st.pop(); for(int i=0; i<s.size(); i++){ if(s[i]=='(' && ans[i]=='.') st.push(i); else if(s[i]==')'){ if(st.size()!=0){ ans[st.top()]='B'; ans[i]='G'; st.pop(); } } } while(st.size()!=0) st.pop(); for(int i=s.size()-1; i>=0; i--){ if(s[i]==')' && ans[i]=='.')st.push(i); else if(s[i]=='(' && ans[i]=='R'){ if(st.size()!=0){ ans[st.top()]='B'; ans[i]='G'; st.pop(); } } } bool flag=true; for(int i=0; i<ans.size(); i++){ if(ans[i]=='.')flag=false; } if(flag) cout<<ans<<endl; else cout<<"impossible\n"; } } }
Compilation message
# | 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 | 0 ms | 348 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 | 0 ms | 348 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 | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 376 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 436 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 376 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 436 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 13 ms | 604 KB | Output is correct |
17 | Correct | 4 ms | 860 KB | Output is correct |
18 | Correct | 3 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 | 109 ms | 2172 KB | Output is correct |
22 | Correct | 35 ms | 5196 KB | Output is correct |
23 | Correct | 28 ms | 2400 KB | Output is correct |
24 | Correct | 34 ms | 3108 KB | Output is correct |
25 | Correct | 34 ms | 5196 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |