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;
void solve(int n) {
vector<int> a(n);
int l = 0;
int r = n - 1;
while (l < n - 1) {
if (query(l + 1, r) == n - 1) {
++l;
} else {
break;
}
}
a[l] = 1;
int curr_max = 1;
for (int i = l + 1; i < n; ++i) {
a[i] = query(l + 1, i + 1);
if (a[i] > curr_max) {
curr_max = a[i];
} else {
a[i] = a[i - 1] - query(i - 1 + 1, i + 1);
}
}
for (int i = l - 1; i >= 0; --i) {
a[i] = query(i + 1, l + 1);
if (a[i] > curr_max) {
curr_max = a[i];
} else {
a[i] = a[i - 1] - query(i + 1, i + 1 + 1);
}
}
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... |