# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64406 | Bodo171 | parentrises (BOI18_parentrises) | C++14 | 4 ms | 484 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=1000005;
string s;
char ans[nmax];
int st1[nmax],st2[nmax];
int tip,cnt,u,t,i,u1,u2,p1;
int main()
{
//freopen("data.in","r",stdin);
cin>>tip;
if(tip==1)
{
cin>>t;
for(int cnt=1;cnt<=t;cnt++)
{
cin>>s;u1=u2=0;
bool ok=1;
for(i=0;i<s.size();i++)
{
if(s[i]=='(')
{
st1[++u1]=i;
st2[++u2]=i;
}
else
{
if(u1)
{
ans[st1[u1]]='R';
u1--;
ans[i]='R';
}
else
{
if(u2)
{
ans[st2[u2]]='G';
u2--;
ans[i]='B';
}
}
}
}
p1=1;
for(i=0;i<s.size();i++)
if(s[i]==')')
{
if(p1<=u1&&st1[p1]<=i)
{
ans[st1[p1]]='B';
p1++;
ans[i]='G';
}
}
for(i=0;i<s.size();i++)
if(!ans[i])
ok=0;
if(p1<=u1||(!ok))
{
cout<<"impossible\n";
continue;
}
cout<<ans<<'\n';
for(i=0;i<s.size();i++)
ans[i]=0;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |