Submission #1331796

#TimeUsernameProblemLanguageResultExecution timeMemory
1331796apxoCoreputer (IOI23_coreputer)C++20
80 / 100
0 ms412 KiB
#include "coreputer.h"
#include "bits/stdc++.h"
using namespace std;

#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif

std::vector<int> malfunctioning_cores(int n) {
	int l = 0, r = n - 1, pos = -1;
	vector<int> res(n), st(n, -1);
	while (l <= r) {
	  int mid = (l + r) >> 1;
	  vector<int> cand(mid + 1);
    iota(cand.begin(), cand.end(), 0);
    st[mid] = run_diagnostic(cand);
    if (st[mid] >= 0) {
      pos = mid;
	    r = mid - 1;
   } else l = mid + 1;
  }
  res[pos] = 1;
  if (pos != n - 1) {
    vector<int> cand(pos);
    iota(cand.begin(), cand.end(), 0);
    for (int i = pos + 1; i < n; ++i) {
      cand.push_back(i);
      res[i] = run_diagnostic(cand) >= 0;
      cand.pop_back();
    }
    cand.resize(n - pos - 1);
    iota(cand.begin(), cand.end(), pos + 1);
    for (int i = pos - 1; i >= 0; --i) {
      cand.push_back(i);
      res[i] = run_diagnostic(cand) > -st[pos];
      cand.pop_back();
    }
  }
  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...