Submission #400983

#TimeUsernameProblemLanguageResultExecution timeMemory
400983jairRSFinding Routers (IOI20_routers)C++17
70.13 / 100
2 ms296 KiB
#include "routers.h"
#define pb push_back
using namespace std;

std::vector<int> find_routers(int l, int n, int q) {
  vector<int> ans = {0};

	int lastRouterIndex = 0;
	for (int toFind = 1; toFind <= n - 1; toFind++)
	{
		int lo = lastRouterIndex + 1, hi = l;
		while(lo <= hi){
			int mid = (lo + hi)/2;
			int detected = use_detector(mid);
			if(detected >= toFind) hi = mid - 1;
			else lo = mid + 1;
		}
		
		int nextRouter = lastRouterIndex + (lo - 1 - lastRouterIndex)*2;
		ans.pb(nextRouter);
		lastRouterIndex = nextRouter;
	}

	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...