Submission #101586

#TimeUsernameProblemLanguageResultExecution timeMemory
101586rainyCake (CEOI14_cake)C++14
10 / 100
2094 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'){ 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 (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:19: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:22: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...