Submission #1088451

#TimeUsernameProblemLanguageResultExecution timeMemory
1088451MateiKing80Coreputer (IOI23_coreputer)C++17
Compilation error
0 ms0 KiB
#include "coreputer.h" #include <vector> using namespace std; vector<int> malfunctioning_cores(int N) { vector<int> id(N); iota(id.begin(), id.end(), 0); vector<int> ans(N, 0), res(N, -2); int l = 0, r = N - 1; while(l <= r) { int m = (l + r) / 2; res[m] = run_diagnostic(vector<int>(id.begin(), id.begin() + m + 1)); if(res[m] == -1) l = m + 1; else r = m - 1; } ans[l] = 1; if(l == N - 1) return ans; if(l == 0) { if(run_diagnostic({0}) != 0) return ans; int L = 1, R = N - 1; while(L <= R) { int M = (L + R) / 2; if(res[M] == -2) res[M] = run_diagnostic(vector<int>(id.begin(), id.begin() + M + 1)); if(res[M] == 0) L = M + 1; else R = M-1; } ans[L] = 1; return ans; } vector<int> v(id.begin(), id.begin()+l); for(int i = l + 1; i < N; i ++) { v.push_back(i); if(run_diagnostic(v) != -1) ans[i] = 1, v.pop_back(); } v = vector<int>(id.begin() + l + 1, id.end()); if(!res[l]) { while(!v.empty() && !ans[v.back()]) v.pop_back(); v.pop_back(); } for(int i = l - 1; i > 0; i --) { v.push_back(i); if(run_diagnostic(v) != -1) ans[i] = 1, v.pop_back(); } int c1 = 0, c2 = 0; for(int i = l; i > 0; i --) c1 += ans[i]; for(int i = l + 1; i < N; i ++) c2 += ans[i]; if((res[l] == 0 && c1 < c2) || (res[l] == 1 && c1 == c2)) ans[0] = 1; return ans; }

Compilation message (stderr)

coreputer.cpp: In function 'std::vector<int> malfunctioning_cores(int)':
coreputer.cpp:9:5: error: 'iota' was not declared in this scope
    9 |     iota(id.begin(), id.end(), 0);
      |     ^~~~