Submission #347072

#TimeUsernameProblemLanguageResultExecution timeMemory
347072PetyFinding Routers (IOI20_routers)C++14
100 / 100
8 ms876 KiB
#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)

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:20:55: warning: variable 'poz' set but not used [-Wunused-but-set-variable]
   20 |     int st = max(p[i - 1], lim2[i - 1]), dr = lim[i], poz = 0;
      |                                                       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...