Submission #1096286

#TimeUsernameProblemLanguageResultExecution timeMemory
1096286huyngoPrisoner Challenge (IOI22_prison)C++17
65 / 100
9 ms1116 KiB
#include "prison.h"
#include<bits/stdc++.h>
using namespace std;

int Bit(int x, int i) {
    return x >> i & 1;
}

std::vector<std::vector<int>> devise_strategy(int N) {
    vector<vector<int>> s(25, vector<int>(N + 1, 0));

    s[0][0] = 1;
    for (int j = 1; j <= N; ++j)
        s[0][j] = 12 + Bit(j, 12) * 12;

    for (int i = 1; i <= 24; ++i) {
        int pos = (i <= 12 ? i : i - 12);
        int obit = i > 12;
        s[i][0] = pos & 1;
        for (int j = 1; j <= N; ++j) {
            if (Bit(j, pos) != obit) {
                if (obit == 0)
                    s[i][j] = (pos & 1) ? -1 : -2;
                else
                    s[i][j] = (pos & 1) ? -2 : -1;
            }
            else {
                if (pos == 1)
                    s[i][j] = (j & 1) ? -1 : -2;
                else
                    s[i][j] = pos - 1 + Bit(j, pos - 1) * 12;
            }
        }
    }
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...