# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502330 | vrohak | Xylophone (JOI18_xylophone) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
odg2=d[0];
zj1[1] = 0; zj1[2] = og2;
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 * (sss * 2 - 1);
}
int mn = 0, mx=0, idx1, idxn;
for (int i = 1; i <= n; i++) {
if(rj1[i] < mn){
mn = zj1[i];
idx1 = i;
}
if(rj1[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, rj1[i]);
}
} else {
for (int i = 1; i <= n; i++) {
answer(i, rj2[i]);
}
}
return;
}