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>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define pii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define ll long long
using namespace std;
inline ll read(){
ll x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
void solve(int N){
int A[N],D[N],B[N];
rep(i,1,N-1)D[i]=query(i,i+1);
rep(i,2,N-1)B[i]=query(i-1,i+1);
bool up=1;
A[0]=0,A[1]=D[1];
rep(i,2,N-1){
if(D[i-1]+D[i]!=B[i])up^=1;
if(up)A[i]=A[i-1]+D[i];
else A[i]=A[i-1]-D[i];
}
int mn=0,mx=0,mxp=0,mnp=0;
rep(i,1,N-1){
if(A[i]>mx)mx=A[i],mxp=i;
if(A[i]<mn)mn=A[i],mnp=i;
}
if(mnp<mxp){
rep(i,0,N-1){
answer(i+1,A[i]-mn+1);
}
}else{
rep(i,0,N-1){
answer(i+1,mx-A[i]+1);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |