이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |