답안 #69979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69979 2018-08-22T07:44:07 Z baqargam parentrises (BOI18_parentrises) C++14
0 / 100
3 ms 564 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--;cout<<i<<" "<<vr.size()<<" "<<vl.size()<<" "<<endl;
            if(vr.size()>2*vl.size()) cout<<"impossible"<<endl;
            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(){
      ^
parentrises.cpp: In function 'int main()':
parentrises.cpp:38:13: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
             else
             ^~~~
parentrises.cpp:39:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
                 vr.push_back(i),bal--;cout<<i<<" "<<vr.size()<<" "<<vl.size()<<" "<<endl;
                                       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 564 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 564 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 564 KB Unexpected end of file - int32 expected