#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));
	srand(time(0));
	while(vec.size()!=1){
		ll x=0;
		for(ll i=0;i<N;i++){
			if(rand()%2){
				x^=(1<<i);
			}
		}
		vll t;
		ll res=run_diagnostic(vect(x));
		for(ll y:vec){
			ll q=__builtin_popcount(y&x);
			ll w=__builtin_popcount(y&(~x));
			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... |