Submission #1201316

#TimeUsernameProblemLanguageResultExecution timeMemory
1201316AMel0nFinding Routers (IOI20_routers)C++20
100 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #include "routers.h" vector<int> x; void solve(int l, int r, int il, int ir) { if (il >= ir) return; // need 2 indexes for comparison if (l == r) { x[il] = l-1; // idk why i-1; // binary searching the first x[i] such that x[i] is the midpoint between p[i] and p[i+1] return ; } int m = (l+r)/2; int im = use_detector(m); solve(l, m, il, im); solve(m+1, r, im, ir); } vector<int> find_routers(int l, int n, int q) { x.resize(n); solve(1, l, 0, n-1); // incl, incl, incl, incl vector<int> res(n); for(int i = 1; i < n; i++) res[i] = (x[i-1]*2 - res[i-1]); // (res[i] + res[i-1]) / 2 = x[i-1] return res; } // signed main() { // cin.tie(0); ios::sync_with_stdio(false); // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...