Submission #101591

# Submission time Handle Problem Language Result Execution time Memory
101591 2019-03-19T04:45:55 Z rainy Cake (CEOI14_cake) C++14
20 / 100
2000 ms 2936 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2096 ms 424 KB Time limit exceeded
2 Execution timed out 2054 ms 384 KB Time limit exceeded
3 Execution timed out 2068 ms 384 KB Time limit exceeded
4 Execution timed out 2043 ms 384 KB Time limit exceeded
5 Execution timed out 2045 ms 604 KB Time limit exceeded
6 Execution timed out 2021 ms 512 KB Time limit exceeded
7 Execution timed out 2050 ms 512 KB Time limit exceeded
8 Execution timed out 2031 ms 512 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 94 ms 1656 KB Output is correct
2 Correct 68 ms 1656 KB Output is correct
3 Correct 63 ms 1528 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 137 ms 2936 KB Output is correct
6 Correct 146 ms 2936 KB Output is correct
7 Correct 133 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 419 ms 504 KB Output isn't correct
2 Incorrect 672 ms 632 KB Output isn't correct
3 Execution timed out 2036 ms 1028 KB Time limit exceeded
4 Execution timed out 2041 ms 1020 KB Time limit exceeded
5 Incorrect 750 ms 836 KB Output isn't correct
6 Execution timed out 2011 ms 1144 KB Time limit exceeded
7 Execution timed out 2043 ms 668 KB Time limit exceeded
8 Execution timed out 2049 ms 1152 KB Time limit exceeded
9 Execution timed out 2037 ms 2404 KB Time limit exceeded
10 Execution timed out 2013 ms 1376 KB Time limit exceeded
11 Execution timed out 2027 ms 780 KB Time limit exceeded
12 Execution timed out 2007 ms 1912 KB Time limit exceeded
13 Execution timed out 2082 ms 2448 KB Time limit exceeded