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;
using ll = long long;
int n;
vector<int> malfunctioning_cores(int N) {
n = N;
int l = 0, r = n - 1;
int parity = 1;
while (l < r) {
int mid = (l + r) / 2;
vector<int> t;
for (int i = 0;i <= mid;i++) t.push_back(i);
int res = run_diagnostic(t);
if (res >= 0) {
r = mid;
parity = min(parity, res);
}
else l = mid + 1;
}
vector<int> ans(n, 0);
ans[l] = 1;
int now = 1;
if (l == n - 1) {
return ans;
}
// trycheck
for (int i = 0;i < l;i++) {
vector<int> t;
for (int j = 0;j <= l;j++) if (j != i) t.push_back(j);
if (run_diagnostic(t) < 0) ans[l] = 1, now ^= 1;
}
for (int i = l + 1;i < n - 1;i++) {
vector<int> t;
for (int j = 0;j < l;j++) t.push_back(j);
t.push_back(i);
if (run_diagnostic(t) >= 0) ans[l] = 1, now ^= 1;
}
ans[n - 1] = now ^ parity;
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... |