# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58380 | 3zp | Xylophone (JOI18_xylophone) | C++14 | 134 ms | 972 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;
int A[5009],B[5009],C[5009];
void solve(int N) {
int M = 1, t = 1;
for(int i = 2; i <= N; i++)
A[i] = query(i-1,i);
for(int i = 3; i <= N; i++)
B[i] = query(i-2,i);
C[2] = 1;
for(int i = 3; i <= N; i++){
if(B[i] == A[i] + A[i-1])
C[i] = C[i-1]; else
C[i] = 1- C[i-1];
}
B[1] = 0;
int X = 0;
for(int i = 2; i <= N; i++){
if(C[i]) B[i] = A[i] + B[i-1];
else B[i] = -A[i] + B[i-1];
X = min(X,B[i]);
}
int a = 0, b = 0;
for(int i = 1; i <= N; i++){
B[i] -= X-1;
if(B[i] == 1) a = i;
if(B[i] == N) b = i;
}
if(a > b)
for(int i = 1; i <= N; i++)
B[i] = N + 1 - B[i];
for(int i = 1; i <= N; i++)
answer(i, B[i]);
//i i-2 i-1
}
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... |