| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 334592 | rocks03 | Finding Routers (IOI20_routers) | C++14 | 8 ms | 768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int use_detector(int x);
vector<int> ask;
int use_use_detector(int x){
if(ask[x] != -1)
return ask[x];
return (ask[x] = use_detector(x));
}
vector<int> find_routers(int l, int n, int q){
ask.resize(l + 1, -1);
vector<int> ans(n);
vector<int> mn(n, 0), mx(n, l);
ans[0] = 0;
for(int i = 1; i < n; i++){
int l = max(mn[i-1], ans[i - 1]), r = mx[i];
while(r - l > 1){
int m = (l + r) / 2;
int idx = use_use_detector(m);
for(int j = idx; j < n; j++){
mn[j] = max(mn[j], m);
}
for(int j = idx; j >= 0; j--){
mx[j] = min(mx[j], m);
}
if(i <= idx){
r = m;
} else{
l = m;
}
}
ans[i] = 2 * (r - 1 - ans[i - 1]) + ans[i - 1];
}
return ans;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
