# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347072 | Pety | Finding Routers (IOI20_routers) | C++14 | 8 ms | 876 KiB |
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>
#include "routers.h"
using namespace std;
int answer[100002], lim[1002], lim2[1002];
int ask (int x) {
if (answer[x] != -1)
return answer[x];
return answer[x] = use_detector(x);
}
vector<int> find_routers (int l, int n, int q) {
vector<int>p;
p.resize(n);
memset(answer, -1, sizeof(answer));
for (int i = 0; i < n; i++)
lim[i] = l;
for (int i = 1; i < n; i++) {
int st = max(p[i - 1], lim2[i - 1]), dr = lim[i], poz = 0;
while (st + 1 < dr) {
int mij = (st + dr) / 2;
int val = ask(mij);
for (int j = 0; j <= val; j++) {
lim[j] = min(lim[j], mij);
}
for (int j = val; j < n; j++) {
lim2[j] = max(lim2[j], mij);
}
if (ask(mij) == i - 1) {
st = mij;
poz = mij;
}
else
dr = mij;
}
p[i] = p[i - 1] + 2* (st - p[i - 1]);
}
return p;
}
/*int main () {
return 0;
}*/
Compilation message (stderr)
# | 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... |