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> find_routers(int l, int n, int q){
vector<int> ans(n), mx(n + 1, 0), mn(n + 1, l + 1);
ans[0] = 0;
for(int i = 1; i < n; i++){
int ql = mx[i - 1], qr = mn[i + 1];
while(qr - ql > 1){
int qm = (ql + qr) / 2;
int id = use_detector(qm);
if(id < i){
ql = qm;
} else{
qr = qm;
}
mn[id] = min(mn[id], qm);
mx[id] = max(mx[id], qm);
}
ans[i] = 2*(ql - ans[i-1]) + ans[i-1];
mx[i] = max(mx[i], ans[i] + 1);
}
return ans;
}
Compilation message (stderr)
routers.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
2 | #pragma GCC optimization("O3")
|
routers.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
3 | #pragma GCC optimization("unroll-loops")
|
# | 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... |