Submission #1073262

#TimeUsernameProblemLanguageResultExecution timeMemory
1073262ZicrusPrisoner Challenge (IOI22_prison)C++17
48.50 / 100
10 ms1372 KiB
#include <bits/stdc++.h>
#include "prison.h"
using namespace std;

typedef long long ll;

int n;

vector<vector<int>> devise_strategy(int N) {
    n = N;
    int x = 31;
    vector<vector<int>> res(x+1, vector<int>(n+1));
    for (int i = 0; i <= x; i++) {
        bool checkA = i%4 == 0;
        int pos = 7-(i/4);
        int k = (int)pow(3, pos);
        res[i][0] = !checkA;
        if (checkA) {
            for (int j = 1; j <= n; j++) {
                res[i][j] = i + (j/k)%3 + 1;
            }
        }
        else {
            for (int j = 1; j <= n; j++) {
                int b = (j/k)%3;
                if (b != i%4-1) {
                    res[i][j] = b < i%4-1 ? -2 : -1;
                    continue;
                }
                res[i][j] = (i/4+1)*4;
                if (res[i][j] > x) res[i][j] = 0;
            }
        }
    }
    return res;
}

#ifdef TEST
#include "grader.cpp"
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...