# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105090 | fve5 | Prisoner Challenge (IOI22_prison) | C++17 | 11 ms | 1272 KiB |
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, int pl, int pr, bool fst, int st) -> void {
if (ans.size() <= st)
ans.resize(st + 1, vector<int>(N + 1));
ans[st][0] = !fst;
for (int i = pl; i <= l; i++)
ans[st][i] = fst ? -1 : -2;
for (int i = r - 1; i < pr; i++)
ans[st][i] = fst ? -2 : -1;
if (r - l <= 2)
return;
int rec_l = st + st % 2 + 1;
int rec_r = st + st % 2 + 2;
int m = (l + r) / 2;
for (int i = l + 1; i < m; i++)
ans[st][i] = rec_l;
for (int i = m; i < r - 1; i++)
ans[st][i] = rec_r;
rec(rec, l, m, l, r, !fst, rec_l);
rec(rec, m, r, l, r, !fst, rec_r);
};
rec(rec, 1, N + 1, 1, N + 1, true, 0);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |