이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;
#define iloop(n) for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
vector<int> malfunctioning_cores(int n){
int l=0,r=n-1;
vector<int> a(n);
a.clear();
iloop(n){
a.pb(0);
}
bool even=0;
while(l<r){
vector<int> v;
int mid=(l+r)/2;
iloop(mid+1){
v.pb(i);
}
int temp=run_diagnostic(v);
if(temp==0){
even=1;
}
if(temp>=0){
r=mid;
} else{
l=mid+1;
}
}
//l is the position of the most left computer st rd(0 to l) is 0 or 1
if(l==0){
vector<int> emptyv;
emptyv.clear();
int temp=run_diagnostic(emptyv);
if(temp==0){
return a;
} else if(temp==-1){
a[0]=1;
return a;
}
}
a[l]=1;
//cout<<even<<" "<<l<<endl;
if(even){
int tot=1;
vector<int> v;
for(int i=0;i<=l;i++){
v.pb(i);
}
for(int i=l+1;i<n;i++){
v.pb(i);
int temp=run_diagnostic(v);
if(temp==1){
a[i]=1;
tot++;
}
v.ppb();
}
v.clear();
for(int i=l+1;i<n;i++){
v.pb(i);
}
for(int i=1;i<l;i++){
v.pb(i);
int temp=run_diagnostic(v);
if(temp==1){
a[i]=1;
tot++;
}
v.ppb();
}
if(tot%2==1){
a[0]=1;
}
return a;
} else{
vector<int> v;
int tot=1;
for(int i=0;i<l;i++){
v.pb(i);
}
for(int i=l+1;i<n;i++){
v.pb(i);
int temp=run_diagnostic(v);
if(temp==1){
a[i]=1;
tot++;
}
v.ppb();
}
v.clear();
for(int i=l+1;i<n;i++){
v.pb(i);
}
for(int i=1;i<l;i++){
v.pb(i);
int temp=run_diagnostic(v);
if(temp==1){
a[i]=1;
tot++;
}
v.ppb();
}
if(tot%2==0){
a[0]=1;
}
return a;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |