Submission #69981

# Submission time Handle Problem Language Result Execution time Memory
69981 2018-08-22T07:52:19 Z baqargam parentrises (BOI18_parentrises) C++14
50 / 100
176 ms 12264 KB
#include<bits/stdc++.h>

using namespace std;

int n,m,k,l,i,j,a,b,bal,li,ri,res[1000005];
string s;
vector<int>vl,vr;

main(){
int p;
cin>>p;

if(p==1)
{
    int t;
    cin>>t;
    while(t--){
        cin>>s;
        n=s.size();
        vl.clear();
        vr.clear();bal=0;li=0;ri=0;
        for(i=0;i<n;i++)res[i]=0;
        for(i=0;i<n;i++){
            if(s[i]=='(')
                vl.push_back(i),bal++;
            else
                vr.push_back(i),bal--;
            if(vr.size()>2*vl.size()) {cout<<"impossible"<<endl;break;}
            if(bal<0){res[vl[li]]=3;li++;res[vr[ri]]=1;ri++;res[vr[ri]]=2;ri++;bal++;}
        }
        if(vr.size()>2*vl.size()) continue;
        vl.clear();
        vr.clear();bal=0;li=0;ri=0;
        for(i=n-1;i>=0;i--){
            if(res[i]!=0) continue;
            if(s[i]==')')
                vl.push_back(i),bal++;
            else
                vr.push_back(i),bal--;
            if(vr.size()>2*vl.size()) {cout<<"impossible"<<endl;break;}
            if(bal<0) {res[vl[li]]=3;li++;res[vr[ri]]=2;ri++;res[vr[ri]]=1;ri++;bal++;}
        }
            if(vr.size()>2*vl.size()) continue;
        for(i=0;i<n;i++){
            if(res[i]==0) cout<<"R";
            if(res[i]==1) cout<<"R";
            if(res[i]==2) cout<<"B";
            if(res[i]==3) cout<<"G";
        }
        cout<<endl;

    }}

}

Compilation message

parentrises.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 532 KB Output is correct
2 Correct 3 ms 532 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 3 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 532 KB Output is correct
2 Correct 3 ms 532 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 3 ms 532 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 2 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 532 KB Output is correct
2 Correct 3 ms 532 KB Output is correct
3 Correct 2 ms 532 KB Output is correct
4 Correct 3 ms 532 KB Output is correct
5 Correct 3 ms 532 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 2 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 4 ms 612 KB Output is correct
12 Correct 3 ms 740 KB Output is correct
13 Correct 3 ms 740 KB Output is correct
14 Correct 4 ms 740 KB Output is correct
15 Correct 5 ms 740 KB Output is correct
16 Correct 24 ms 784 KB Output is correct
17 Correct 12 ms 1808 KB Output is correct
18 Correct 10 ms 1808 KB Output is correct
19 Correct 11 ms 1808 KB Output is correct
20 Correct 15 ms 1824 KB Output is correct
21 Correct 176 ms 1824 KB Output is correct
22 Correct 108 ms 11792 KB Output is correct
23 Correct 84 ms 11792 KB Output is correct
24 Correct 86 ms 11792 KB Output is correct
25 Correct 118 ms 12264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12264 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12264 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 12264 KB Unexpected end of file - int32 expected