Submission #1221381

#TimeUsernameProblemLanguageResultExecution timeMemory
1221381totoroPrisoner Challenge (IOI22_prison)C++20
38 / 100
23 ms1608 KiB
#include "prison.h"

#include <vector>

std::vector<std::vector<int>> devise_strategy(int N) {
    std::vector<std::vector<int>> strategy(39, std::vector<int>(N + 1));
    for (int val = 0; val < 39; ++val) {
        int bitnum = 12 - val / 3;
        int state = val % 3;
        if (state == 0) {
            strategy[val][0] = 0;
            for (int inbaga = 1; inbaga <= N; ++inbaga) {
                if (inbaga & (1 << bitnum)) {
                    strategy[val][inbaga] = 3 * (val / 3) + 2;
                } else {
                    strategy[val][inbaga] = 3 * (val / 3) + 1;
                }
            }
        } else {
            strategy[val][0] = 1;
            for (int inbagb = 1; inbagb <= N; ++inbagb) {
                if (inbagb & (1 << bitnum)) {
                    if (state == 1) {  // A did not have this bit
                        strategy[val][inbagb] = -1;
                    } else {
                        strategy[val][inbagb] = ((val / 3 + 1) * 3) % 39;
                    }
                } else {
                    if (state == 2) {  // A had this bit
                        strategy[val][inbagb] = -2;
                    } else {
                        strategy[val][inbagb] = ((val / 3 + 1) * 3) % 39;
                    }
                }
            }
        }
    }
    return strategy;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...