Submission #301629

#TimeUsernameProblemLanguageResultExecution timeMemory
301629kevinsogoFinding Routers (IOI20_routers)C++17
100 / 100
2 ms416 KiB
#include "routers.h" #include <bits/stdc++.h> using namespace std; vector<int> maxs; void assign(int p, int i) { maxs[i] = max(maxs[i], p); } void solve(int p1, int p2, int i1, int i2) { assign(p1, i1); assign(p2, i2); if (i1 == i2 || p2 - p1 <= 1) return; int pm = p1 + p2 >> 1; int im = use_detector(pm); solve(p1, pm, i1, im); solve(pm, p2, im, i2); } vector<int> find_routers(int l, int n, int q) { maxs = vector<int>(n, -1); solve(1, l, 0, n - 1); vector<int> ans(n); for (int i = 0; i < n - 1; i++) { ans[i + 1] = 2 * maxs[i] - ans[i]; } return ans; }

Compilation message (stderr)

routers.cpp: In function 'void solve(int, int, int, int)':
routers.cpp:14:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   14 |     int pm = p1 + p2 >> 1;
      |              ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...