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 STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 5010
int s2[MAXN], s3[MAXN], A[MAXN];
void solve(int N) {
for(int i = 2; i <= N; i++) s2[i] = query(i-1, i);
for(int i = 3; i <= N; i++) s3[i] = query(i-2, i);
A[1] = 0; A[2] = s2[2];
for(int i = 3; i <= N; i++) {
if(A[i-2] < A[i-1]) {
if(s2[i]+s2[i-1] == s3[i]) A[i] = A[i-1] + s2[i];
else A[i] = A[i-1] - s2[i];
} else if(A[i-2] > A[i-1]) {
if(s2[i]+s2[i-1] == s3[i]) A[i] = A[i-1] - s2[i];
else A[i] = A[i-1] + s2[i];
}
}
int minn = INF, idx1 = 1, idxN = 1;
for(int i = 1; i <= N; i++) minn = min(minn, A[i]);
for(int i = 1; i <= N; i++) {
A[i] += (1-minn);
if(A[i] == 1) idx1 = i;
if(A[i] == N) idxN = i;
}
for(int i = 1; i <= N; i++) answer(i, (idx1 < idxN ? A[i]:N+1-A[i]));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |