# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
389561 | maximath_1 | Xylophone (JOI18_xylophone) | C++11 | 161 ms | 456 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 <vector>
#include <math.h>
#include <iostream>
#include <assert.h>
using namespace std;
int diff[5005];
int ans[5005];
void solve(int N){
for(int i = 2; i <= N; i ++){
if(i == 2) diff[i] = query(i - 1, i);
else{
int nw = query(i - 1, i), bf = query(i - 2, i);
if(abs(nw) + abs(diff[i - 1]) == bf){
diff[i] = nw;
if(diff[i - 1] < 0) diff[i] *= -1;
assert(abs(abs(diff[i - 1]) + abs(diff[i])) == bf);
}else{
diff[i] = nw;
if(diff[i - 1] > 0) diff[i] *= -1;
assert(max(abs(diff[i - 1]), abs(diff[i])) == bf);
}
}
}
ans[1] = 1;
for(int i = 2; i <= N; i ++)
ans[i] = diff[i] + ans[i - 1];
int mn = 69696969, mx = -69696969, mnid = 0, mxid = 0;
for(int i = 1; i <= N; i ++){
if(mn > ans[i]){
mn = ans[i]; mnid = i;
}
if(mx < ans[i]){
mx = ans[i]; mxid = i;
}
}
for(int i = 1; i <= N; i ++)
ans[i] += -mn + 1;
if(mnid > mxid){
ans[1] = 1;
for(int i = 2; i <= N; i ++)
ans[i] = -diff[i] + ans[i - 1];
int mn = 69696969, mx = -69696969, mnid = 0, mxid = 0;
for(int i = 1; i <= N; i ++){
if(mn > ans[i]){
mn = ans[i]; mnid = i;
}
if(mx < ans[i]){
mx = ans[i]; mxid = i;
}
}
for(int i = 1; i <= N; i ++)
ans[i] += -mn + 1;
}
for(int i = 1; i <= N; i ++)
answer(i, 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... |