Submission #101596

#TimeUsernameProblemLanguageResultExecution timeMemory
101596rainyCake (CEOI14_cake)C++14
0 / 100
2100 ms26348 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...