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>> res(25, vector<int>(n + 1));
    res[0][0] = 0;  // bag A
    for (int j = 1; j <= n; ++j) res[0][j] = 1 + (j >> 11 & 1);
    for (int i = 1; i <= 12; ++i) {
        int bag = i & 1;  // look bag BABA alternating
        for (int b = 0; b < 2; ++b) {
            int x = i * 2 - 1 + b;
            res[x][0] = bag;
            for (int j = 1; j <= n; ++j) {
                int c = j >> (12 - i) & 1;
                if (c < b) {
                    if (bag == 0) {  // looking A
                        res[x][j] = -1;
                    } else {
                        res[x][j] = -2;
                    }
                } else if (c > b) {
                    if (bag == 0) {
                        res[x][j] = -2;
                    } else {
                        res[x][j] = -1;
                    }
                } else if (i != 12) {
                    res[x][j] = i * 2 + 1 + (j >> (11 - i) & 1);
                }
            }
        }
    }
    return res;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |