Submission #69980

# Submission time Handle Problem Language Result Execution time Memory
69980 2018-08-22T07:52:08 Z vanogam parentrises (BOI18_parentrises) C++14
0 / 100
3 ms 440 KB
#include<bits/stdc++.h>
using namespace std;
int a,s,d[303][303][303],d1[1000002],pas[303],f,g,h,j,k,l,i,n,m,mod=1000000007;
stack<int> q1,q2;
main(){
    ios::sync_with_stdio(0);
    cin>>j;
    if(j==1){
        cin>>n;
        string x;


        for(i=0;i<n;i++){
            cin>>x;
            j=0;f=0;
            while(q1.size()) q1.pop();
            while(q2.size()) q2.pop();
            for(a=0;a<x.size();a++){
                d1[a]=0;
                if(x[a]=='(') f++;
                else {
                    if(f) {q1.push(a);f--;}
                    else {
                        if(q1.empty()) {cout<<"impossible\n";break;}
                        d1[a]=1;
                        d1[q1.top()]=2;
                        q1.pop();
                        j=a;//cout<<"*";
                    }
                }
            }
            f=0;
            if(a!=x.size()) continue;
            for(a=x.size()-1;a>j;a--){
                if(x[a]==')') f++;
                else {
                    if(f) {q2.push(a);f--;}
                    else {
                        if(q2.empty()) {cout<<"impossible\n";break;}
                        d1[a]=1;
                        d1[q2.top()]=2;
                        q2.pop();
                        //j=a;
                    }
                }
            }
            if(a!=j) continue;
            for(a=0;a<x.size();a++){
                if(d1[a]==0) cout<<"G";
                if(d1[a]==1) cout<<"R";
                if(d1[a]==2) cout<<"B";
            }
            cout<<endl;
        }
    }
    else{
        cin>>n;
        d[0][0][0]=1;
       /* for(i=0;i<=300;i++){
            for(a=0;a<=300;a++){
                for(j=0;j<=300;j++){
                    d[i+1][a][j+1]+=d[i][a][j];
                    if(d[i+1][a][j+1]>mod) d[i+1][a][j+1]-=mod;
                    d[i+1][a+1][j]+=d[i][a][j];
                    if(d[i+1][a+1][j]>mod) d[i+1][a+1][j]-=mod;
                    d[i+1][a+1][j+1]+=d[i][a][j];
                    if(d[i+1][a+1][j+1]>mod) d[i+1][a+1][j+1]-=mod;

                    if(j){
                    d[i+1][a][j-1]+=d[i][a][j];
                    if(d[i+1][a][j-1]>mod) d[i+1][a][j-1]-=mod;}
                    if(a){
                    d[i+1][a-1][j]+=d[i][a][j];
                    if(d[i+1][a-1][j]>mod) d[i+1][a-1][j]-=mod;}
                    if(a && j){
                    d[i+1][a-1][j-1]+=d[i+1][a-1][j-1];
                    if(d[i+1][a-1][j-1]>mod) d[i+1][a-1][j-1]-=mod;}
                }
            }
        }
*/
        for(i=0;i<a;i++){
            cin>>a;
            cout<<d[a][0][0]<<endl;
        }
    }
}

Compilation message

parentrises.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
parentrises.cpp: In function 'int main()':
parentrises.cpp:18:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(a=0;a<x.size();a++){
                     ~^~~~~~~~~
parentrises.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(a!=x.size()) continue;
                ~^~~~~~~~~~
parentrises.cpp:48:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(a=0;a<x.size();a++){
                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 392 KB Output is correct
2 Correct 2 ms 392 KB Output is correct
3 Incorrect 3 ms 392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 392 KB Output is correct
2 Correct 2 ms 392 KB Output is correct
3 Incorrect 3 ms 392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 392 KB Output is correct
2 Correct 2 ms 392 KB Output is correct
3 Incorrect 3 ms 392 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 440 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 440 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 440 KB Unexpected end of file - int32 expected