Submission #839551

#TimeUsernameProblemLanguageResultExecution timeMemory
839551model_codeCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms276 KiB
// correct/sol_db_N+logN-2.cpp #include <bits/stdc++.h> #include "coreputer.h" using namespace std; int ask(vector <int> q, int N) { if (q.size() >= N) { return 1; } else if (q.empty()) { return -1; } else { return run_diagnostic(q); } } vector <int> malfunctioning_cores(int N) { auto fill = [](int endp) { vector <int> result; for (int i = 0; i < endp; ++i) result.push_back(i); return result; }; int resp = 1, p = 0; vector <int> pre; for (int i = 3; i >= 0; --i) { int r = p + (1 << i); pre = fill(r); int res = ask(pre, N); if (res < 0) { p = r; } else { resp = res; } } pre = fill(++p); vector <int> ans(N, 0); int parity = resp & 1, last = p == N? N - 2: N - 1; for (int i = 0; i < N; ++i) { if (i == p - 1) { ans[i] = 1; parity ^= 1; continue; } if (i == last) { continue; } vector <int> simdiff = pre; auto it = find(simdiff.begin(), simdiff.end(), i); if (it != simdiff.end()) { simdiff.erase(it); ans[i] = ask(simdiff, N) != resp; } else { simdiff.pop_back(); simdiff.push_back(i); ans[i] = ask(simdiff, N) == resp; } parity ^= ans[i]; } ans[last] = parity; return ans; }

Compilation message (stderr)

coreputer.cpp: In function 'int ask(std::vector<int>, int)':
coreputer.cpp:8:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |     if (q.size() >= N) {
      |         ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...