#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, cnt2=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-l)
{
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]=0;
else cnt++, res[i]=1;
}
cnt+=(v[l]==0);
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, cnt2++;
else res[i]=0;
}
res[N-1]=cnt2!=cnt;
}
else
{
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, cnt2++;
else res[i]=0;
}
cnt2+=(v[l]==0);
for (int i=0; i<l-1; 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]=0;
else cnt++, res[i]=1;
}
res[l-1]=cnt2!=cnt;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Incorrect |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |