Submission #733273

#TimeUsernameProblemLanguageResultExecution timeMemory
733273puppyPrisoner Challenge (IOI22_prison)C++17
48.50 / 100
17 ms1364 KiB
#include "prison.h" #include <vector> #include <iostream> using namespace std; int mul[] = {1, 3, 9, 27, 81, 243, 729, 2187, 6561}; //3^7까지 int get_bit(int X, int k) { return (X % mul[k+1]) / mul[k]; } std::vector<std::vector<int>> devise_strategy(int N) { vector<vector<int>> s(32, vector<int>(N+1)); for (int i = 0; i <= 7; i++) { for (int k = 0; k < 3; k++) { //3i + k + 1: A의 3^(7-i) 비트 봤더니 k네요 s[3*i+k+1][0] = 1; for (int j = 1; j <= N; j++) { int bt = get_bit(j, 7 - i); if (k < bt) s[3*i+k+1][j] = -1; else if (i == 7 || k > bt) s[3*i+k+1][j] = -2; else s[3*i+k+1][j] = 25 + i; } } } s[0][0] = 0; for (int j = 1; j <= N; j++) { int bt = get_bit(j, 7); s[0][j] = bt + 1; } for (int i = 0; i <= 6; i++) { //s[25+i] 채우기. s[25+i][0] = 0; //3^(7-i)까지 봤음. 3^(6-i) 볼 차례 for (int j = 1; j <= N; j++) { int bt = get_bit(j, 6 - i); s[25+i][j] = 3 * (i + 1) + bt + 1; } } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...