Submission #525351

#TimeUsernameProblemLanguageResultExecution timeMemory
525351safaricolaXylophone (JOI18_xylophone)C++17
0 / 100
1 ms200 KiB
#include "xylophone.h" static int ans[5010],diff1[5010],diff2[5010],mi,ma,miid,maid; static bool greate[5010]; void solve(int N) { for(int i=1; i<N; i++){ diff1[i]=query(i,i+1); if(i!=N-1){ diff2[i]=query(i,i+2); } } ans[1]=1; //greater=1, i<i+1; for(int i=1; i<N; i++){ if(greate[i]){ ans[i+1]=ans[i]+diff1[i]; if(ans[i+1]>ma){ ma=ans[i+1]; maid=i+1; } } else{ ans[i+1]=ans[i]-diff1[i]; if(ans[i+1]<mi){ mi=ans[i+1]; miid=i+1; } } if(diff1[i+1]+diff1[i]==diff2[i]){ greate[i+1]=greate[i]; }else{ greate[i+1]=!greate[i]; } } if(mi<1){ for(int i=1; i<=N; i++){ ans[i]+=1-mi; } } if(miid>maid){ for(int i=1; i<=N; i++){ ans[i]=N+1-ans[i]; } } for(int i = 1; i <= N; i++) { answer(i, ans[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...