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 "prison.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<std::vector<int>> devise_strategy(int N) {
    vector<vector<int>>ret;
    vector<pair<int, int>>S = {{1, N}};
    vector<pair<int, int>>S_;
    while (!S.empty())
    {
        S_ = {};
        int x = (int)ret.size();
        ret.push_back(vector<int>(N + 1, 0));
        ret.push_back(vector<int>(N + 1, 0));
        ret.push_back(vector<int>(N + 1, 0));
        vector<int>&v = ret[x];
        vector<int>&v1 = ret[x + 1];
        vector<int>&v2 = ret[x + 2];
        v[0] = 0;
        v2[0] = 1;
        v1[0] = 1;
        bool bent2 = false;
        for (int i = 0; i < (int)S.size(); i++)
        {
            int lo = S[i].first;
            int hi = S[i].second;
            v[lo] = -1;
            v[hi] = -2;
            v1[lo] = -2;
            v1[hi] = -1;
            v2[lo] = -2;
            v2[hi] = -1;
            lo++;
            hi--;
            if (hi - lo + 1 >= 2)
                bent2 = true;
            if (lo <= hi)
            {
                int m = (lo + hi) / 2;
                if (lo < m)
                    S_.push_back({lo, m});
                for (int i = lo; i <= m; i++)
                {
                    v[i] = x + 1;
                    v1[i] = x + 3;
                    v2[i] = -2;
                }
                if (m + 1 < hi)
                    S_.push_back({m + 1, hi});
                for (int i = m + 1; i <= hi; i++)
                {
                    v[i] = x + 2;
                    v2[i] = x + 3;
                    v1[i] = -1;
                }
            }
        }
        if (bent2 == false)
        {
            ret.pop_back();
        }
        S = S_;
    }
    int mx = (int)ret.size() - 1;
    for (vector<int> &i : ret)
        for (int &j : i)
            j = min(j, mx);
    return ret;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |