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;
void answer(int a, int b);
int query(int a, int b);
void solve(int n) {
int cur = query(1, n);
int mn = 1;
vector<int> ans(n + 1);
for (int i = 2; i <= n; i++) {
int tmp = query(i, n);
if (tmp != cur) {
mn = i - 1;
break;
}
cur = tmp;
}
ans[mn] = 1;
cur = 0;
for (int i = mn - 1; i >= 1; i--) {
int tmp = query(i, mn);
if (tmp != cur) {
ans[i] = tmp + 1;
} else {
ans[i] = ans[i + 1] - query(i, i + 1);
}
cur = tmp;
}
cur = 0;
for (int i = mn + 1; i <= n; i++) {
int tmp = query(mn, i);
if (tmp != cur) {
ans[i] = tmp + 1;
} else {
ans[i] = ans[i - 1] - query(i - 1, i);
}
cur = tmp;
}
for (int i = 1; i <= n; i++) {
answer(i, ans[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... |