Submission #101423

#TimeUsernameProblemLanguageResultExecution timeMemory
101423rainyCake (CEOI14_cake)C++14
0 / 100
2067 ms2976 KiB
#include<cstdio> #include<cstring> #include<algorithm> #include<map> using namespace std; int N,Q,A; int d[250000],od[250000]; char aa;int bb,cc; void proc(){ int st=A,en=A;od[A]=0;int nesf=1; while(st!=0||en!=N-1){ //printf("(%d,%d)\n",st,en); if(st==0){ en++;od[en]=nesf; } else if(en==N-1){ st--;od[st]=nesf; } else if(d[st-1]<d[en+1]){ st--;od[st]=nesf; } else{ en++;od[en]=nesf; } nesf++; } } int main(){ scanf("%d%d",&N,&A);A--; for(int i=0;i<N;i++)scanf("%d",&d[i]); scanf("%d",&Q); proc(); for(int it=0;it<Q;it++){ scanf(" %c",&aa); if(aa=='F'){ scanf("%d",&bb);bb--; printf("%d\n",od[bb]); } else{ scanf("%d%d",&bb,&cc); bb--; int orr=d[bb]; cc=N-orr+1; d[bb]=cc; for(int i=0;i<N;i++){ if(d[i]<=orr&&d[i]>cc&&i!=bb)d[i]++; //printf("[%d:%d]\n",i,d[i]); } proc(); } } return 0; }

Compilation message (stderr)

cake.cpp: In function 'int main()':
cake.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&A);A--;
     ~~~~~^~~~~~~~~~~~~~
cake.cpp:32:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<N;i++)scanf("%d",&d[i]);
                         ~~~~~^~~~~~~~~~~~
cake.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&Q);
     ~~~~~^~~~~~~~~
cake.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&aa);
         ~~~~~^~~~~~~~~~~
cake.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&bb);bb--;
             ~~~~~^~~~~~~~~~
cake.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d",&bb,&cc);
             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...