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;
#define bug(x) cerr << #x << " " << x << endl;
void solve(int N) {
int n = N;
vector<int> dif( n + 1 ), x( n + 1, 1 );
for( int i = 2; i <= n; i++ ){
dif[i] = query( i - 1, i );
if( i > 2 ){
int aux = query( i - 2, i );
if( aux == dif[i - 1] || aux == dif[i] ) x[i] = -x[i - 1];
else x[i] = x[i - 1];
}
}
pair<int, int> maxi( 0, 1 ), mini( 0, 1 );
for( int i = 2, sum = 0; i <= n; i++ ){
sum += dif[i]*x[i];
maxi = max( maxi, make_pair( sum, i ) );
mini = min( mini, make_pair( sum, i ) );
}
int val;
if( maxi.second < mini.second ){
val = 1 + abs(maxi.first);
for( int i = 2; i <= n; i++ ) x[i] = -x[i];
}
else val = 1 + abs(mini.first);
answer( 1, val );
for( int i = 2; i <= n; i++ ){
val += dif[i]*x[i];
answer( i, val );
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |