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 <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int N = 5e3 + 10;
int a[N], df[N], st[N], mul = 1, mn, mx, pmn, pmx;
//void answer( int pos, int va ) { printf("pos : %d va : %d\n",pos,va); }
/*int query( int i, int j ) {
int c;
printf("%d %d\n",i,j);
scanf("%d",&c);
return c;
}*/
void solve( int n ) {
for( int i = 1 ; i < n ; i++ ) df[i+1] = query( i, i + 1 );
for( int i = 2 ; i < n ; i++ ) {
int dif = query( i-1, i+1 );
if( dif == df[i] + df[i+1] ) st[i] = 1;
else st[i] = -1;
}
pmx = 1, pmn = 1;
for( int i = 2 ; i <= n ; i++ ) {
a[i] = a[i-1] + ( mul * df[i] );
mul *= st[i];
if( a[i] > mx ) mx = a[i], pmx = i;
if( a[i] < mn ) mn = a[i], pmn = i;
}
/*for( int i = 2 ; i <= n ; i++ ) printf("%d ",df[i]);
printf("\n");
for( int i = 2 ; i < n ; i++ ) printf("%d ",st[i]);
printf("\n");
printf("%d %d pos : %d %d\n",mn,mx,pmn,pmx);*/
if( pmn > pmx ) {
for( int i = 1 ; i <= n ; i++) a[i] *= -1;
swap( mn, mx );
mn *= -1, mx *= -1;
}
//printf("%d %d pos : %d %d\n",mn,mx,pmn,pmx);
for( int i = 1 ; i <= n ; i++ ) answer( i, a[i] + -1*mn + 1 );
}
/*int main() {
int n;
scanf("%d",&n);
solve( n );
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |