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 <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
/*int query (int a,int b){
cout<<a<<" "<<b<<endl;
int pes;
cin>>pes;
return pes;
}*/
void solve(int n) {
int rj1[n], sss = 0, rj2[n];
rj1[1] = 0;
int odg1, odg2, odg3;
rj1[2] = odg1;
odg2 = query(1, 2);
for (int i = 3; i < n + 1; i++) {
odg1 = odg2;
odg2 = query(i - 1, i);
odg3 = query(i - 2, i);
if (sss == 0) {
if (odg3 == odg2 + odg1) {
rj1[i] = rj1[i - 1] + odg2;
} else {
sss = 1;
rj1[i] = rj1[i - 1] - odg2;
}
} else {
if (odg3 == odg2 + odg1) {
rj1[i] = rj1[i - 1] - odg2;
} else {
sss = 0;
rj1[i] = rj1[i - 1] + odg2;
}
}
}
int mn = 0, mx=0, idx1=0, idxn=0;
for (int i = 1; i < n + 1; i++) {
if(rj1[i] < mn) idx1 = i;
if(rj1[i] > mx) idxn = i;
mn = min(mn, rj1[i]);
mx = max(mx, rj1[i]);
}
mn = abs(mn) + 1;
for (int i = 1; i < n + 1; i++) {
rj2[i] = mx-rj1[i]+1;
rj1[i] = rj1[i] + mn;
}
if (idx1 < idxn) {
for (int i = 1; i < n + 1; i++) {
answer(i, rj1[i]);
}
} else {
for (int i = 1; i < n + 1; i++) {
answer(i, rj2[i]);
}
}
return;
}
Compilation message (stderr)
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:21:11: warning: 'odg1' is used uninitialized in this function [-Wuninitialized]
21 | rj1[2] = odg1;
| ~~~~~~~^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |