#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> malfunctioning_cores(int N){
vector<int> them;
int cur;
int ret;
vector<int> q;
for(int a=0; a<N; a++){
cur = a;
q.push_back(cur);
ret = run_diagnostic(q);
if(ret != -1){
them.push_back(cur);
break;
}
}
for(int a=cur+1; a<N; a++){
q.pop_back();
q.push_back(a);
if(run_diagnostic(q) != -1){
them.push_back(a);
}
}
int cmp = them.size(); //either half + 1 or half + 1/2
int k;
if(ret == 1){
k = cmp;
}
else{
k = cmp - 1;
}
q.clear();
for(int a=0; a<k; a++){
q.push_back(them[a]);
}
for(int a=0; a<cur; a++){
q.pop_back();
q.push_back(a);
if(run_diagnostic(q) != -1){
them.push_back(a);
}
}
sort(them.begin(), them.end(), greater<int>());
vector<int> r;
for(int a=0; a<N-1; a++){
if(them.back() == a){
r.push_back(1);
them.pop_back();
}
else{
r.push_back(0);
}
}
return r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |