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;
#define pb push_back
vector<int> malfunctioning_cores(int N) {
vector<int> mal(N);
int lo = 0, hi = N - 1, ans = -1, ret = -1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
vector<int> qu_vec;
for (int i = 0; i <= mid; i++) {
qu_vec.pb(i);
}
int tmp = run_diagnostic(qu_vec);
if (tmp >= 0) {
ans = mid;
ret = tmp;
hi = mid - 1;
} else {
lo = mid + 1;
}
}
assert(ans != -1);
if (ans == N - 1) {
mal.back() = 1;
return mal;
}
vector<int> qu_vec;
for (int i = 0; i <= ans; i++) {
qu_vec.pb(i);
}
for (int i = 0; i < ans; i++) {
qu_vec.erase(find(qu_vec.begin(), qu_vec.end(), i));
if (run_diagnostic(qu_vec) == -1) {
mal[i] = 1;
}
qu_vec.pb(i);
}
mal[ans] = 1;
qu_vec.erase(find(qu_vec.begin(), qu_vec.end(), ans));
for (int i = ans + 1; i + 1 < N; i++) {
qu_vec.pb(i);
if (run_diagnostic(qu_vec) >= 0) {
mal[i] = 1;
}
qu_vec.pop_back();
}
int parity = count(mal.begin(), mal.end(), 1) % 2;
mal.back() = (parity != ret);
return mal;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |