# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210278 | eric_xiao | Xylophone (JOI18_xylophone) | C++14 | 0 ms | 0 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[100009],lf[100009],lf2[100009];
void solve(int N)
{
int i,j,k,mn = 1000000000;
//vector<int> ck;
A[1] = 0;
A[2] = A[1]+query(1,2);
ck.push_back(A[1]);
ck.push_back(A[2]);
mn = min(A[1],A[2]);
for(i = 3;i <= N;i++)
{
lf[i] = query(i-1,i);
lf2[i] = query(i-2,i);
A[i] = A[i-1]+lf[i];
if(max({A[i],A[i-1],A[i-2]}) - min({A[i],A[i-1],A[i-2]}) != lf2[i])
{
A[i] = A[i-1] - lf[i];
}
mn = min(mn,A[i]);
}
int cg = 0,sm = 0;
for(i = 1;i <= N;i++)
{
A[i] = A[i] - mn + 1;
if(A[i] == 1) sm = 1;
if(A[i] == N)
{
if(sm == 1) cg = 1;
}
}
if(cg == 1)
{
for(i = 1;i <= N;i++)
{
A[i] = N + 1 - A[i];
}
}
for(i = 1;i <= N;i++)
{
answer(i,A[i]);
}
}