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 <iostream>
#include <vector>
using namespace std;
int a[5005], b[5005], c[5005], dd[5005];
void solve(int n) {
if (n == 2) {
answer(1, 1);
answer(2, 2);
return;
}
for (int i = 1; i <= n - 1; i++) {
b[i] = query(i, i + 1);
}
for (int i = 1; i <= n - 2; i++) {
c[i] = query(i, i + 2);
if (c[i] == b[i] + b[i + 1]) dd[i] = 0;
else dd[i] = 1;
}
int d = 0, mi = 0, ma = 0, g = 0, h = 0, flag = 0, f = 0;
for (int i = 1; i < n; i++) {
if (flag == 1) d += b[i];
else d -= b[i];
if (ma < d) {
ma = d;
g = i;
}
if (mi > d) {
mi = d;
h = i;
}
if (flag != dd[i]) flag = 1;
else flag = 0;
}
if (g <= h) f = 1;
mi = d = 0;
for (int i = 1; i < n; i++) {
if (f == 1) d += b[i];
else d -= b[i];
mi = min(mi, d);
if (f != dd[i]) f = 1;
else f = 0;
a[i + 1] = d;
}
for (int i = 1; i <= n; i++) {
a[i] += 1 - mi;
}
for (int i = 1; i <= n; i++) {
answer(i, 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... |