Submission #1200444

#TimeUsernameProblemLanguageResultExecution timeMemory
1200444aykhnFinding Routers (IOI20_routers)C++20
99.71 / 100
1 ms328 KiB
#include "routers.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> find_routers(int L, int n, int q) 
{
  int K = 1;
  while (K < L / (n - 1)) K <<= 1;
  vector<int> x = {0};
  int last = 0, l = 1;
  while (x.size() < n)
  {
    int y = use_detector(min(L, last + K));
    while (x.size() != y + 1)
    {
      int r = min(L, last + K);
      while (l < r)
      {
        int mid = (l + r) >> 1;
        if (use_detector(mid) == (int)x.size() - 1) l = mid + 1;
        else r = mid;
      }
      x.push_back(l);
      l++;
    }
    last += K;
    l = last + 1;
  }
  vector<int> res = {0};
  for (int i = 1; i < n; i++)
  {
    int d = x[i] - 1 - res[i - 1];
    res.push_back(res[i - 1] + d * 2);
  }
  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...