제출 #1078812

#제출 시각아이디문제언어결과실행 시간메모리
1078812The_Samurai죄수들의 도전 (IOI22_prison)C++17
56 / 100
10 ms1116 KiB
#include "prison.h"
#include "bits/stdc++.h"
using namespace std;

std::vector<std::vector<int>> devise_strategy(int n) {
    int x = 26;
    vector ans(x + 1, vector(n + 1, 0));
    for (int i = 0; i <= x; i++) {
        if (i == 0) {
            ans[i][0] = 0;
            for (int j = 1; j <= n; j++) {
                ans[i][j] = 1 + ((j & (1 << 12)) > 0 ? 1 : 0);
            }
        } else if ((i - 1) % 4 <= 1) {
            ans[i][0] = 1;
            int a = (i - 1) % 4, k = 12 - (i - 1) / 2;
            for (int j = 1; j <= n; j++) {
                int b = (j & (1 << k)) > 0;
                if (a == b) {
                    b = (j & (1 << (k - 1))) > 0;
                    ans[i][j] = i - a + 2 + b;
                    if (ans[i][j] > x) ans[i][j] = 0;
                    continue;
                }
                ans[i][j] = (a > b ? -2 : -1);
            }
        } else {
            ans[i][0] = 0;
            int b = (i - 3) % 4, k = 12 - (i - 1) / 2;
            for (int j = 1; j <= n; j++) {
                int a = (j & (1 << k)) > 0;
                if (a == b) {
                    a = (j & (1 << (k - 1))) > 0;
                    ans[i][j] = i - b + 2 + a;
                    
                    continue;
                }
                ans[i][j] = (a > b ? -2 : -1);
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...