Submission #1162226

#TimeUsernameProblemLanguageResultExecution timeMemory
1162226mateuszwesFinding Routers (IOI20_routers)C++20
70.13 / 100
1 ms328 KiB
#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){
		int mid = (poc+kon+1)/2;

		//deb(mid);
		int ok = use_detector(mid);
		if(ok == last) poc = mid;
		else if(ok < last) poc = mid+1;
		else kon = mid-1;

		//deb2(poc, kon);
	}
	return poc;
}

vector<int> find_routers(int l, int n, int q) {
    vector<int> ans(n);
    for(int i = 1; i < n; i++){
    	int coc = bs(i-1, (ans[i-1]),l)-ans[i-1];
		ans[i] = ans[i-1]+2*coc;
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...