# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
626796 | flashmt | Prisoner Challenge (IOI22_prison) | C++17 | 1 ms | 212 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>
using namespace std;
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(21, vector<int>(n + 1, -1));
for (int i = 0; i <= 20; i++)
ans[i][0] = 0;
function<void(int, int, int, int)> solve = [&](int turn, int row, int low, int high)
{
int curBag = turn % 2, otherBag = curBag ^ 1;
ans[row][0] = curBag;
ans[row][low++] = -curBag - 1;
if (high > low)
ans[row][--high] = -otherBag - 1;
int rem = high - low;
if (rem <= 1)
return;
vector<int> nextRows;
if (rem <= 4) // divide into block of size 2
{
for (int i = 0; i < rem; i++)
ans[row][low + i] = turn * 3 + i / 2 + 1;
solve(turn + 1, turn * 3 + 1, low, min(low + 2, high));
nextRows.push_back(turn * 3 + 1);
if (rem > 2)
{
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |