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>
#define FOR(i,l,r) for(int i=(l); i<=(r); ++i)
#define REP(i,l,r) for(int i=(l); i<(r); ++i)
#define FORD(i,r,l) for(int i=(r); i>=(l); --i)
#define REPD(i,r,l) for(int i=(r)-1; i>=(l); --i)
using namespace std;
int sz, ans[1005], rangel[1005], ranger[1005];
int use_detector(int x);
void update(int tmp, int x) {
REP(i, 0, tmp) ranger[i] = min(ranger[i], x - 1);
REP(i, tmp + 1, sz) rangel[i] = max(rangel[i], x + 1);
rangel[tmp] = x;
}
int ask(int x) {
int tmp = use_detector(x);
update(tmp, x);
return tmp;
}
void solve(int l, int r, int num) {
int mid;
while (l < r) {
mid = (l + r + 1) / 2;
if (ask(mid) > num) r = mid - 1;
else l = mid;
}
ans[num] = l;
}
vector<int> find_routers(int l, int n, int q) {
sz = n;
REP(i, 0, n) ranger[i] = l;
REP(i, 0, n - 1) {
solve(rangel[i], ranger[i], i);
}
vector<int> List(n, 0);
REP(i, 1, n) List[i] = ans[i - 1] * 2 - List[i - 1];
return List;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |