This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> malfunctioning_cores(int N) {
int lo = 0, hi = N - 1, last;
while (lo < hi) {
int mid = (lo + hi) / 2;
vector<int> ask(mid + 1);
iota(ask.begin(), ask.end(), 0);
last = run_diagnostic(ask);
if (last == -1) lo = mid + 1;
else hi = mid;
}
vector<int> ans(N, 0);
ans[lo] = 1;
bool odd = true;
int cnt = 1;
for (int i = 0; i < N; i++) {
if (i == lo) continue;
if (N == 16 && (i == N - 1 || (lo == N - 1 && i == N - 2))) {
if (cnt % 2 != odd) ans[i] = 1, cnt++;
continue;
}
if (i > lo) {
vector<int> ask = {i};
for (int j = 0; j < lo; j++) ask.push_back(j);
int tmp = run_diagnostic(ask);
if (tmp == 0) odd = false;
if (tmp != -1) ans[i] = 1, cnt++;
} else {
vector<int> ask = {};
for (int j = 0; j <= lo; j++) if (j != i) ask.push_back(j);
int tmp = run_diagnostic(ask);
if (tmp == 0) odd = false;
if (tmp == -1) ans[i] = 1, cnt++;
}
}
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... |