# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102444 | Dat160601 | Xylophone (JOI18_xylophone) | C++17 | 87 ms | 512 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;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 5007;
int p[N];
void solve(int n){
if(n == 1){
answer(1, 1);
return;
}
p[1] = 0;
p[2] = query(1, 2);
for(int i = 3; i <= n; i++){
int ret1 = query(i - 1, i), ret2 = query(i - 2, i);
if(p[i - 1] > p[i - 2]){
if(ret2 == ret1 + abs(p[i - 1] - p[i - 2])) p[i] = p[i - 1] + ret1;
else p[i] = p[i - 1] - ret1;
}
else{
if(ret2 == ret1 + abs(p[i - 1] - p[i - 2])) p[i] = p[i - 1] - ret1;
else p[i] = p[i - 1] + ret1;
}
}
int val = 1e9;
for(int i = 1; i <= n; i++){
if(p[i] < val) val = p[i];
}
int pos1, posn;
for(int i = 1; i <= n; i++){
p[i] += (1 - val);
if(p[i] == 1) pos1 = i;
if(p[i] == n) posn = i;
}
if(pos1 > posn){
for(int i = 1; i <= n; i++){
p[i] = n - p[i] + 1;
}
}
for(int i = 1; i <= n; i++) answer(i, p[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... |