# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896131 | Andrey | Xylophone (JOI18_xylophone) | C++14 | 58 ms | 600 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"
#include<bits/stdc++.h>
using namespace std;
void solve(int N) {
int n = N;
vector<int> dif(n-1);
dif[0] = query(1,2);
for(int i = 1; i < n-1; i++) {
dif[i] = query(i+1,i+2);
if((abs(dif[i-1])+dif[i] == query(i,i+2)) == (dif[i-1] < 0)) {
dif[i]*=-1;
}
}
vector<int> ans(n);
ans[0] = 0;
int sm = 0,p1,p2;
for(int i = 1; i < n; i++) {
ans[i] = ans[i-1]+dif[i-1];
sm = min(sm,ans[i]);
}
for(int i = 0; i < n; i++) {
ans[i] = ans[i]-sm+1;
if(ans[i] == 1) {
p1 = i;
}
else if(ans[i] == n) {
p2 = i;
}
}
if(p1 > p2) {
for(int i = 0; i < n; i++) {
ans[i] = n-ans[i]+1;
}
}
for(int i = 0; i < n; i++) {
answer(i+1,ans[i]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |