Submission #1081573

#TimeUsernameProblemLanguageResultExecution timeMemory
1081573faricaPrisoner Challenge (IOI22_prison)C++17
65 / 100
10 ms1116 KiB
#include "prison.h"

#include <bits/stdc++.h>

using namespace std;

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) {
        if((1LL<<12)&j) s[0][j] = 24;
        else s[0][j] = 12;
    }
    for(int i=1; i<25; ++i) {
        s[i][0] = i%2;
        for(int j=1; j<=N; ++j) {
            if(i > 12) {
                int bit = i - 12;
                if((1LL<<bit) & j) {
                    --bit;
                    if(!bit) {
                        if(j%2) s[i][j] = (i%2 == 0 ? -2 : -1);
                        else s[i][j] = ((i+1)%2 == 0 ? -2 : -1);
                    } else {
                        if((1LL<<bit) & j) s[i][j] = bit + 12;
                        else s[i][j] = bit;
                    }
                } else s[i][j] = ((i+1)%2 == 0 ? -2 : -1);
            } else {
                if((1LL<<i) & j) s[i][j] = (i%2 == 0 ? -2 : -1);
                else {
                    int bit = i - 1;
                    if(!bit) {
                        if(j%2) s[i][j] = (i%2 == 0 ? -2 : -1);
                        else s[i][j] = ((i+1)%2 == 0 ? -2 : -1);
                    } else {
                        if((1LL<<bit) & j) s[i][j] = bit + 12;
                        else s[i][j] = bit;
                    }
                }
            }
        }
    }

    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...