Submission #502336

#TimeUsernameProblemLanguageResultExecution timeMemory
502336vrohakXylophone (JOI18_xylophone)C++14
100 / 100
111 ms348 KiB
#include "xylophone.h" void solve(int n) { // ako je x pozitivan //ako je x pozitivan //ako je x pozitivan //ako je x // pozitivan //ako je x pozitivan //ako je x pozitivan //ako je x pozitivan // //ako je x pozitivan int zj1[n+1], zj2[n+1]; int d[n+1], t[n+1], og1, og2, og3; bool sss=true; for(int i=1;i<n;i++){ d[i] = query(i, i+1); if(i!=1) t[i] = query(i-1, i+1); } og2=d[1]; zj1[1] = 0; zj1[2] = d[1]; for (int i = 3; i <= n; i++) { og1 = d[i-2]; og2 = d[i-1]; og3 = t[i-1]; if(og1+og2 != og3){ sss = !sss; } zj1[i] = zj1[i-1] + og2 * ((int)sss * 2 - 1); } int mn = 0, mx=0, idx1=0, idxn=0; for (int i = 1; i <= n; i++) { if(zj1[i] < mn){ mn = zj1[i]; idx1 = i; } if(zj1[i] > mx){ mx = zj1[i]; idxn = i; } } mn = -mn + 1; for (int i = 1; i <= n; i++) { zj2[i] = mx-zj1[i]+1; zj1[i] = zj1[i] + mn; } if (idx1 < idxn) { for (int i = 1; i <= n; i++) { answer(i, zj1[i]); } } else { for (int i = 1; i <= n; i++) { answer(i, zj2[i]); } } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...