| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1285373 | minhjulzi | Finding Routers (IOI20_routers) | C++20 | 0 ms | 0 KiB |
#include "routers.h"
#include <bits/stdc++.h>
using namespace std;
#define task "task"
#define bit(x, i) ((x >> i) & 1)
// https://trap.jp/post/1224/
#define FOR1(i, a, b) for(int i = (a), _b = (b); i <= _b; i ++)
#define FOR2(i, a, b, c) for(int i = (a), _b = (b); i <= _b; i += c)
#define FORD1(i, a, b) for(int i = (a), _b = (b); i >= _b; i --)
#define FORD2(i, a, b, c) for(int i = (a), _b = (b); i >= _b; i -= c)
#define overload4(a, b, c, d, name, ...) name
#define FOR(...) overload4(__VA_ARGS__, FOR2, FOR1)(__VA_ARGS__)
#define FORD(...) overload4(__VA_ARGS__, FORD2, FORD1)(__VA_ARGS__)
#define pb emplace_back
#define pf emplace_front
#define ins emplace
#define mp make_pair
#define fi first
#define se second
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
// mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
// ll rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll>(l, r)(rd); }
const int N = 1e5 + 5;
const ll inf = 1e18;
const int mod = 1e9 + 7;
const int base = 31;
void dnc(int l, int r, int optl, int optr, vector<int> &ans){
if(l > r) return;
if(optl == optr){
a[l] = optl;
return;
}
int mid = optl + optr >> 1;
int pos = use_detector(mid);
dnc(l, pos - 1, optl, mid, ans);
dnc(pos + 1, r, mid, optr, ans);
}
vector<int> find_routers(int l, int n, int q){
vector<int> ans(n);
dnc(1, n - 1, 1, l, ans);
/*
mi = (ai + ai+1) / 2 -> choose i
mi + 1 -> choose i + 1
*/
FOR(i, 1, n - 1) ans[i] = 2 * ans[i] - a[i - 1] - 2;
return ans;
}
// void solve(){
// }
// signed main(){
// ios::sync_with_stdio(false);
// cin.tie(NULL);
// if(fopen(task".inp", "r")){
// freopen(task".inp", "r", stdin);
// freopen(task".out", "w", stdout);
// }
// int nTest = 1;
// // cin>>nTest;
// while(nTest --) solve();
// cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
// return 0;
// }
