Submission #842624

#TimeUsernameProblemLanguageResultExecution timeMemory
842624WLZCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms600 KiB
#include "coreputer.h" #include <bits/stdc++.h> using namespace std; std::vector<int> malfunctioning_cores(int N) { int lo = 0, hi = N - 1, last; while (lo < hi) { int mid = (lo + hi) / 2; vector<int> ask(mid + 1); iota(ask.begin(), ask.end(), 0); last = run_diagnostic(ask); if (last == -1) lo = mid + 1; else hi = mid; } vector<int> ans(N, 0); ans[lo] = 1; bool odd = true; int cnt = 1; for (int i = 0; i < N; i++) { if (i == lo) continue; if (N == 16 && (i == N - 1 || (lo == N - 1 && i == N - 2))) { if (cnt % 2 != odd) ans[i] = 1, cnt++; continue; } if (i > lo) { vector<int> ask = {i}; for (int j = 0; j < lo; j++) ask.push_back(j); int tmp = run_diagnostic(ask); if (tmp == 0) odd = false; if (tmp != -1) ans[i] = 1, cnt++; } else { vector<int> ask = {}; for (int j = 0; j <= lo; j++) if (j != i) ask.push_back(j); int tmp = run_diagnostic(ask); if (tmp == 0) odd = false; if (tmp == -1) ans[i] = 1, cnt++; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...