# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941652 | benjaminkleyn | Finding Routers (IOI20_routers) | C++17 | 3 ms | 860 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;
map<int, int> mem;
int detect(int x)
{
if (mem.find(x) != mem.end())
return mem[x];
return mem[x] = use_detector(x);
}
vector<int> find_routers(int l, int n, int q) {
l -= l % 2;
mem = map<int, int>();
vector<int> ans(n, 0);
mem[0] = 0;
for (int i = 0, x = 0; i < n - 1; i++)
{
int prev = x;
for (int k = 7; k >= 0; k--)
while (x + (1 << k) <= l && detect(x + (1 << k)) == i)
x += (1 << k);
ans[i + 1] = x + (x - ans[i]);
}
return ans;
}
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... |