답안 #64409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64409 2018-08-04T10:45:10 Z Bodo171 parentrises (BOI18_parentrises) C++14
0 / 100
3 ms 484 KB
#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';
                        }
                        else ok=0;
                    }
                }
            }
            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))
            {
                for(i=0;i<s.size();i++)
                 ans[i]=0;
                cout<<"impossible\n";
                continue;
            }
            cout<<ans<<'\n';
            for(i=0;i<s.size();i++)
              ans[i]=0;
        }
    }
    return 0;
}

Compilation message

parentrises.cpp: In function 'int main()':
parentrises.cpp:21:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i=0;i<s.size();i++)
                     ~^~~~~~~~~
parentrises.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i=0;i<s.size();i++)
                     ~^~~~~~~~~
parentrises.cpp:59:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i=0;i<s.size();i++)
                     ~^~~~~~~~~
parentrises.cpp:64:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(i=0;i<s.size();i++)
                         ~^~~~~~~~~
parentrises.cpp:70:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i=0;i<s.size();i++)
                     ~^~~~~~~~~
parentrises.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("data.in","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 484 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 484 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 484 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 484 KB Unexpected end of file - int32 expected