Submission #307097

#TimeUsernameProblemLanguageResultExecution timeMemory
307097phathnvFinding Routers (IOI20_routers)C++14
100 / 100
2 ms768 KiB
#include "routers.h" #include <bits/stdc++.h> using namespace std; int asked[200001]; int ask(int x){ if (asked[x] != -1) return asked[x]; asked[x] = use_detector(x); return asked[x]; } vector <int> find_routers(int l, int n, int q){ vector <int> res; res.push_back(0); int cur = 0; for(int i = 0; i <= l; i++) asked[i] = -1; if (n == 2){ int mid = 1; for(int j = 16; j >= 0; j--){ if (mid + (1 << j) > l) continue; if (ask(mid + (1 << j)) == 0) mid += (1 << j); } res.push_back(2 * mid); return res; } for(int i = 1; i < n; i++){ int mid = cur + 1; while (ask(min(l, mid + 64)) == i - 1) mid = min(l, mid + 64); for(int j = 5; j >= 0; j--){ if (mid + (1 << j) > l) continue; if (ask(mid + (1 << j)) == i - 1) mid += (1 << j); } int nxt = 2 * mid - cur; res.push_back(nxt); cur = nxt; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...