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>
#include "prison.h"
using namespace std;
vector<vector<int>> devise_strategy(int N) {
vector<vector<int>> ans;
auto rec = [&](auto &&rec, int l, int r, bool fst) -> int {
int sz = ans.size();
ans.emplace_back(N + 1);
ans[sz][0] = fst;
int m = (l + r) / 2;
int ll, rr;
if (r - l > 1) {
ll = rec(rec, l, m, !fst);
rr = rec(rec, m, r, !fst);
}
for (int i = 1; i <= N; i++) {
if (i <= l)
ans[sz][i] = fst ? -2 : -1;
else if (i >= r - 1)
ans[sz][i] = fst ? -1 : -2;
else if (i < m)
ans[sz][i] = ll;
else
ans[sz][i] = rr;
}
return sz;
};
rec(rec, 1, N + 1, true);
return ans;
}
Compilation message (stderr)
prison.cpp: In lambda function:
prison.cpp:29:28: warning: 'rr' may be used uninitialized in this function [-Wmaybe-uninitialized]
29 | ans[sz][i] = rr;
prison.cpp:27:28: warning: 'll' may be used uninitialized in this function [-Wmaybe-uninitialized]
27 | ans[sz][i] = ll;
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |