Submission #909209

#TimeUsernameProblemLanguageResultExecution timeMemory
909209pavementCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms596 KiB
#include "coreputer.h" #include <bits/stdc++.h> using namespace std; #define pb push_back vector<int> malfunctioning_cores(int N) { vector<int> mal(N); int lo = 0, hi = N - 1, ans = -1, ret = -1; while (lo <= hi) { int mid = (lo + hi) / 2; vector<int> qu_vec; for (int i = 0; i <= mid; i++) { qu_vec.pb(i); } int tmp = run_diagnostic(qu_vec); if (tmp >= 0) { ans = mid; ret = tmp; hi = mid - 1; } else { lo = mid + 1; } } assert(ans != -1); if (ans == N - 1) { mal.back() = 1; return mal; } vector<int> qu_vec; for (int i = 0; i <= ans; i++) { qu_vec.pb(i); } for (int i = 0; i < ans; i++) { qu_vec.erase(find(qu_vec.begin(), qu_vec.end(), i)); if (run_diagnostic(qu_vec) == -1) { mal[i] = 1; } qu_vec.pb(i); } mal[ans] = 1; qu_vec.erase(find(qu_vec.begin(), qu_vec.end(), ans)); for (int i = ans + 1; i + 1 < N; i++) { qu_vec.pb(i); if (run_diagnostic(qu_vec) >= 0) { mal[i] = 1; } qu_vec.pop_back(); } int parity = count(mal.begin(), mal.end(), 1) % 2; mal.back() = (parity != ret); return mal; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...