This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "coreputer.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
std::vector<int> malfunctioning_cores(int N) {
int lo = 0, hi = N - 2, ans = -1, cnt = 0, lmao[16];
for(int i = 0; i < N; i++)lmao[i] = 5;
while(lo <= hi){
int mid = (lo + hi) >> 1;
vector <int> x;
for(int j = 0; j <= mid; j++)x.push_back(j);
int res = run_diagnostic(x);
cnt++;
//cout << mid << ' ';
lmao[mid] = res;
if(res == 1)hi = mid - 1;
else ans = mid, lo = mid + 1;
}
//cout << cnt << ' ' << ans << '\n';
if(ans == -1){
vector <int> x;
x.push_back(1);
for(int i = 0 ; i < N - 1; i++)x.push_back(0);
return x;
}
assert(ans != N - 1);
vector <int> bruh(N, 0);
bruh[ans + 1] = 1;
int ptr = ans + 1;
if(lmao[ans] == -1)ptr++;
//cout << ans << ' ' << cnt << '\n';
for(int i = 0; i <= ans; i++){
if(ptr == N)break;
vector <int> x;
for(int j = 0; j <= i; j++)x.push_back(j);
for(int j = ptr; j < N; j++)x.push_back(j);
int res = run_diagnostic(x);
if(res == 1){
bruh[i] = 1;
if(ptr == ans + 1)ptr++;
else {
while(ptr < N){
ptr++;
if(ptr == N){
bruh[N - 1] = 1;
break;
}
//cout << ptr << ' ';
x.clear();
for(int j = 0; j <= i; j++)x.push_back(j);
for(int j = ptr; j < N; j++)x.push_back(j);
int ret = run_diagnostic(x);
if(ret != 1){
bruh[ptr - 1] = 1;
break;
}
}
}
}
}
return bruh;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |