#include "coreputer.h"
#include<vector>
#include<numeric>
#include<random>
using namespace std;
using ll=int;
using vll=vector<ll>;
vll to_vector(ll x, ll n){
vll vec;
while(n--){
vec.push_back(x%2);
x/=2;
}
return vec;
}
vll vect(ll x){
vll res;
for(ll i=0;i<32;i++){
if(x&(1<<i)){
res.push_back(i);
}
}
return res;
}
std::vector<int> malfunctioning_cores(int N) {
vll vec((1<<N)-1);
iota(vec.begin(),vec.end(),1);
mt19937 rng(time(0));
while(vec.size()!=1){
ll x=uniform_int_distribution<ll>(1,(1<<N)-1)(rng);
vll t;
ll res=run_diagnostic(vect(x));
for(ll y:vec){
if(res==1){
if(__builtin_popcount(y&x)>__builtin_popcount(y&(!x))){
t.push_back(y);
}
}
if(res==0){
if(__builtin_popcount(y&x)==__builtin_popcount(y&(!x))){
t.push_back(y);
}
}
if(res==-1){
if(__builtin_popcount(y&x)<__builtin_popcount(y&(!x))){
t.push_back(y);
}
}
}
vec=t;
}
return to_vector(vec[0],N);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |