Submission #941652

#TimeUsernameProblemLanguageResultExecution timeMemory
941652benjaminkleynFinding Routers (IOI20_routers)C++17
74.76 / 100
3 ms860 KiB
#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)

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:21:13: warning: unused variable 'prev' [-Wunused-variable]
   21 |         int prev = x;
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...