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 idx,s=1;
int l=0,r=n-1;
while(l<r){
int m=(l+r)/2;
vector<int> v;
for(int i=0;i<=m;i++)v.push_back(i);
int x=run_diagnostic(v);
if(x==-1)l=m+1;
else{
r=m;
s=x;
}
}
idx=l;
vector<int> ans(n);
if(s){
vector<int> v;
for(int i=0;i<idx;i++)v.push_back(i);
ans[idx]=1;
for(int i=idx+1;i<n;i++){
v.push_back(i);
ans[i]=run_diagnostic(v)==1;
v.pop_back();
}
v.clear();
for(int i=idx+1;i<n;i++)v.push_back(i);
for(int i=0;i<idx;i++){
v.push_back(i);
ans[i]=run_diagnostic(v)==1;
v.pop_back();
}
}else{
vector<int> v;
for(int i=0;i<=idx;i++)v.push_back(i);
ans[idx]=1;
for(int i=idx+1;i<n-1;i++){
v.push_back(i);
ans[i]=run_diagnostic(v)==1;
v.pop_back();
}
v.clear();
for(int i=idx+1;i<n;i++)v.push_back(i);
for(int i=0;i<idx;i++){
v.push_back(i);
ans[i]=run_diagnostic(v)==1;
v.pop_back();
}
for(int i=0;i<n-1;i++)ans[n-1]^=ans[i];
}
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... |