제출 #1329905

#제출 시각아이디문제언어결과실행 시간메모리
132990512345678Coreputer (IOI23_coreputer)C++17
100 / 100
1 ms412 KiB
#include "coreputer.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> malfunctioning_cores(int N) {
	int l=0, r=N-1, cnt=0;
	vector<int> res(N), v(N);
	while (l<r)
	{
		int md=(l+r)/2;
		vector<int> qrs;
		for (int i=0; i<=md; i++) qrs.push_back(i);
		if ((v[md]=run_diagnostic(qrs))>=0) r=md;
		else l=md+1;
	}
	res[l]=1;
	if (l==N-1) return res; 
	for (int i=0; i<l; i++)
    {
        vector<int> qrs;
        for (int j=0; j<=l; j++) if (j!=i) qrs.push_back(j);
        if (run_diagnostic(qrs)<0) res[i]=1; 
    }
    for (int i=l+1; i<N-1; i++)
    {
        vector<int> qrs;
        for (int j=0; j<l; j++) qrs.push_back(j);
        qrs.push_back(i);
        if (run_diagnostic(qrs)>=0) res[i]=1;
    }
    for (int i=0; i<N-1; i++) if (res[i]) cnt++;
	int expected_parity=v[l];
    if (cnt%2!=expected_parity) res[N-1]=1;
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...