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 rj1[n+1], rj2[n+1];
int d[n+1], t[n+1], odg1, odg2, odg3;
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[1];
rj1[1] = 0; rj1[2] = odg2;
for (int i = 3; i <= n; i++) {
odg1 = d[i-2];
odg2 = d[i-1];
odg3 = t[i-1];
if(odg1+odg2 != odg3){
sss = !sss;
}
rj1[i] = rj1[i-1] + odg2 * ((int)sss * 2 - 1);
}
int mn = 0, mx=0, idx1=0, idxn=0;
for (int i = 1; i <= n; i++) {
if(rj1[i] < mn){
mn = rj1[i];
idx1 = i;
}
if(rj1[i] > mx){
mx = rj1[i];
idxn = i;
}
}
mn = -mn + 1;
for (int i = 1; i <= n; i++) {
rj2[i] = mx-rj1[i]+1;
rj1[i] = rj1[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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |