#include "routers.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pii pair<int,int>
#define pl pair<ll,ll>
#define F first
#define S second
#define pq priority_queue
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " = " << x << '\n';
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << '\n';
int bs(int last, int poc, int kon){ //szuka najwiekszego gdzie use detector zwraca last
while(kon-poc > 1){
int mid = (poc+kon)/2;
if(use_detector(mid) == last) poc = mid;
else kon = mid-1;
}
if(use_detector(kon) == last) return kon;
return poc;
}
vector<int> find_routers(int l, int n, int q) {
vector<int> ans(n);
for(int i = 1; i < n; i++){
ans[i] = ans[i-1]+2*(bs(i-1, ans[i-1]+1,l)-ans[i-1]);
}
return ans;
}
# | 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... |