Submission #710723

#TimeUsernameProblemLanguageResultExecution timeMemory
710723t6twotwo죄수들의 도전 (IOI22_prison)C++17
80 / 100
12 ms980 KiB
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int get(int x, int k) {
    while (k--) x /= 3;
    return x % 3;
}
vector<vector<int>> devise_strategy(int N) {
    vector ans(23, vector<int>(N + 1));
    for (int i = 0; i < 23; i++) {
        int x = 7 - (i + 2) / 3;
        ans[i][0] = (x + 1) % 2;
        for (int j = 1; j <= N; j++) {
            if (i == 22) {
                ans[i][j] = -1 - (j % 3 == 2);
            } else if (i && (i + 2) % 3 != get(j, x + 1)) {
                ans[i][j] = -1 - (((i + 2) % 3 > get(j, x + 1)) ^ (x % 2));
            } else if (i >= 19) {
                int t = get(j, x);
                if (t != 1) {
                    ans[i][j] = -1 - !t;
                } else {
                    ans[i][j] = 22;
                }
            } else {
                ans[i][j] = (i + 2) / 3 * 3 + get(j, x) + 1;
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...