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>
using namespace std;
#include "xylophone.h"
static int A[5000];
const int N = 1e5 + 10;
int a[N], b[N], c[N], d[N], cnt[N];
int n;
void Find(int e[]) {
for(int i = 3; i <= n; i++) {
e[i] = e[i - 1] + a[i];
if (max({e[i - 2], e[i - 1], e[i]}) - min({e[i - 2], e[i - 1], e[i]}) != b[i])
e[i] = e[i - 1] - a[i];
}
int p = 0;
for(int i = 1; i <= n; i++) p = max(p, 1 - e[i]);
for(int i = 1; i <= n; i++) e[i] += p;
}
void solve(int _n) {
n = _n;
for(int i = 2; i <= n; i++) a[i] = query(i - 1, i);
for(int i = 3; i <= n; i++) b[i] = query(i - 2, i);
c[2] = a[2];
d[2] = -a[2];
Find(c); Find(d);
int mx = 0, mn = 0;
bool ok = 1;
for(int i = 1; i <= n; i++) {
if (c[i] == 1) mn = i;
if (c[i] == n) mx = i;
if (1 <= c[i] && c[i] <= n) cnt[c[i]]++;
else ok = 0;
if (cnt[c[i]] > 1) ok = 0;
}
if (ok && mn < mx && query(mn, mx) == n - 1) for(int i = 1; i <= n; i++) answer(i, c[i]);
else for(int i = 1; i <= n; i++) answer(i, d[i]);
}
Compilation message (stderr)
xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
4 | static int A[5000];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |