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 rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
vector<int>malfunctioning_cores(int n) {
bool zero=false;
vector<int>ans(n);
int po=1, ko=n;
int ile=0;
while(po<ko) {
int sr=(po+ko)/2;
vector<int>P;
rep(j, sr) P.pb(j);
int x=run_diagnostic(P);
++ile;
if(x==0) zero=true;
if(x==-1) po=sr+1; else ko=sr;
}
ans[po-1]=1;
if(po==n) return ans;
rep(i, po-1) {
vector<int>P;
rep(j, po) if(j!=i) P.pb(j);
int x=run_diagnostic(P);
++ile;
if(x==0) zero=true;
if(x==-1) ans[i]=1;
}
for(int i=po; i<n-1; ++i) {
vector<int>P;
rep(j, po-1) P.pb(j);
P.pb(i);
int x=run_diagnostic(P);
++ile;
if(x==0) zero=true;
if(x!=-1) ans[i]=1;
}
if(ile<18) {
vector<int>P;
rep(j, po) P.pb(j);
int x=run_diagnostic(P);
++ile;
if(x==0) zero=true;
}
int sum=0;
for(auto i : ans) sum^=i;
if(sum==zero) ans[n-1]=1;
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... |