Submission #101596

# Submission time Handle Problem Language Result Execution time Memory
101596 2019-03-19T04:54:03 Z rainy Cake (CEOI14_cake) C++14
0 / 100
2000 ms 26348 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define MAXN 250005
using namespace std;
int N,A,Q,d[MAXN],od[MAXN];
map<int,int>dtp;

int main(){
    scanf("%d%d",&N,&A);
    for(int i=1;i<=N;i++){
        scanf("%d",&d[i]);
        dtp[d[i]]=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;
                    map<int,int>temp=dtp;
                    dtp[d[I]]=I;
                    for(int j=orr+1;j<d[I];j++){
                        int pos=temp[j];
                        d[pos]--;
                        dtp[j]=pos;
                    }
                }
                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;
                    map<int,int>temp=dtp;
                    dtp[d[I]]=I;
                    for(int j=orr+1;j<d[I];j++){
                        int pos=temp[j];
                        d[pos]--;
                        dtp[j]=pos;
                    }
                }
                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:11: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:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&d[i]);
         ~~~~~^~~~~~~~~~~~
cake.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&Q);
     ~~~~~^~~~~~~~~
cake.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("  %c",&inp);
         ~~~~~^~~~~~~~~~~~~
cake.cpp:53: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:56: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 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2016 ms 1268 KB Time limit exceeded
2 Execution timed out 2044 ms 1280 KB Time limit exceeded
3 Execution timed out 2033 ms 1368 KB Time limit exceeded
4 Execution timed out 2025 ms 1368 KB Time limit exceeded
5 Execution timed out 2016 ms 2816 KB Time limit exceeded
6 Execution timed out 2043 ms 2936 KB Time limit exceeded
7 Execution timed out 2041 ms 2816 KB Time limit exceeded
8 Execution timed out 2045 ms 2900 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 10880 KB Time limit exceeded
2 Incorrect 1402 ms 11148 KB Output isn't correct
3 Incorrect 1027 ms 11104 KB Output isn't correct
4 Correct 2 ms 256 KB Output is correct
5 Execution timed out 2031 ms 26200 KB Time limit exceeded
6 Execution timed out 2028 ms 26076 KB Time limit exceeded
7 Execution timed out 2033 ms 26348 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2035 ms 952 KB Time limit exceeded
2 Execution timed out 2021 ms 900 KB Time limit exceeded
3 Execution timed out 2024 ms 5368 KB Time limit exceeded
4 Execution timed out 2037 ms 5376 KB Time limit exceeded
5 Execution timed out 2031 ms 924 KB Time limit exceeded
6 Execution timed out 2028 ms 6904 KB Time limit exceeded
7 Execution timed out 2040 ms 1280 KB Time limit exceeded
8 Execution timed out 2045 ms 10616 KB Time limit exceeded
9 Execution timed out 2033 ms 25800 KB Time limit exceeded
10 Execution timed out 2040 ms 1092 KB Time limit exceeded
11 Execution timed out 2037 ms 2304 KB Time limit exceeded
12 Execution timed out 2059 ms 20596 KB Time limit exceeded
13 Execution timed out 2100 ms 25724 KB Time limit exceeded