제출 #101591

#제출 시각아이디문제언어결과실행 시간메모리
101591rainy케이크 (CEOI14_cake)C++14
20 / 100
2096 ms2936 KiB
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 250005
using namespace std;
int N,A,Q,d[MAXN],od[MAXN];

int main(){
    scanf("%d%d",&N,&A);
    for(int i=1;i<=N;i++)scanf("%d",&d[i]);
    scanf("%d",&Q);
    bool prevE=true;
    int I=-1,E=-1;
    for(int i=0;i<Q;i++){
        char inp;
        scanf("  %c",&inp);
        if(inp=='E'){
            if(prevE){
                if(I!=-1&&E!=-1){
                    int orr=d[I];
                    d[I]=N-E+1;
                    for(int j=0;j<N;j++){
                        if(j!=I&&d[j]>orr&&d[j]<=d[I])d[j]--;
                    }
                }
                int s=A,e=A,sf=1;
                while(!(s==1&&e==N)){
                    if(s==1){
                        e++;od[e]=sf;
                    }
                    else if(e==N){
                        s--;od[s]=sf;
                    }
                    else if(d[s-1]<d[e+1]){
                        s--;od[s]=sf;
                    }
                    else{
                        e++;od[e]=sf;
                    }
                    sf++;
                }
            }
            prevE=true;
            scanf("%d%d",&I,&E);
        }
        else{
            int B;scanf("%d",&B);
            if(prevE){
                if(I!=-1&&E!=-1){
                    int orr=d[I];
                    d[I]=N-E+1;
                    for(int j=0;j<N;j++){
                        if(j!=I&&d[j]>orr&&d[j]<=d[I])d[j]--;
                    }
                }
                int s=A,e=A,sf=1;
                while(!(s==1&&e==N)){
                    if(s==1){
                        e++;od[e]=sf;
                    }
                    else if(e==N){
                        s--;od[s]=sf;
                    }
                    else if(d[s-1]<d[e+1]){
                        s--;od[s]=sf;
                    }
                    else{
                        e++;od[e]=sf;
                    }
                    sf++;
                }
            }
            printf("%d\n",od[B]);
            prevE=false;
        }
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

cake.cpp: In function 'int main()':
cake.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&A);
     ~~~~~^~~~~~~~~~~~~~
cake.cpp:10:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=N;i++)scanf("%d",&d[i]);
                          ~~~~~^~~~~~~~~~~~
cake.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&Q);
     ~~~~~^~~~~~~~~
cake.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("  %c",&inp);
         ~~~~~^~~~~~~~~~~~~
cake.cpp:44:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d",&I,&E);
             ~~~~~^~~~~~~~~~~~~~
cake.cpp:47:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int B;scanf("%d",&B);
                   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...