Submission #1032861

#TimeUsernameProblemLanguageResultExecution timeMemory
103286142kangarooPrisoner Challenge (IOI22_prison)C++17
0 / 100
0 ms348 KiB
#include "prison.h" #include <vector> std::vector<std::vector<int>> devise_strategy(int N) { using namespace std; vector<vector<int>> strat(20, vector<int>(N + 1, 0)); vector<int> p3(8); p3[0] = 1; p3[1] = 4; p3[2] = 8; for (int i = 3; i < 8; ++i) { p3[i] = p3[i - 1]*3; } strat[0][0] = 1; for (int i = 1; i <= N; ++i) { strat[0][i] = (i / p3[7]) + 1; } for (int i = 0; i < 4; ++i) { strat[1 + 3 * i][0] = strat[2 + 3 * i][0] = strat[3 + 3 * i][0] = i % 2; for (int j = 1; j <= N; ++j) { if ((j/p3[7 - i]) % 3 == 0) { strat[2 + 3*i][j] = strat[3 + 3*i][j] = -1 - i % 2; strat[1 + 3 * i][j] = 4 + 3*i + (j/p3[6 - i]) % 3; } else if ((j/p3[7 - i]) % 3 == 1){ strat[3 + 3*i][j] = -1 - i % 2; strat[1 + 3*i][j] = -2 + i%2; strat[2 + 3 * i][j] = 4 + 3*i + (j/p3[6 - i]) % 3; } else { strat[2 + 3*i][j] = strat[1 + 3*i][j] = -2 + i % 2; strat[3 + 3 * i][j] = 4 + 3*i + (j/p3[6 - i]) % 3; } } } strat[13][0] = strat[14][0] = strat[15][0] = 0; for (int j = 1; j <= N; ++j) { if ((j/p3[3]) % 3 == 0) { strat[14][j] = strat[15][j] = -1; strat[13][j] = 16 + (j >> 2) % 2; } else if ((j/p3[3]) % 3 == 1){ strat[15][j] = -1; strat[13][j] = -2; strat[14][j] = 16 + (j >> 2) % 2; } else { strat[14][j] = strat[13][j] = -2; strat[15][j] = 16 + (j >> 2) % 2; } } strat[16][0] = strat[17][0] = 1; for (int i = 0; i < N; ++i) { if (((i + 1) >> 2) % 2 == 0) { strat[17][i + 1] = -1; if (i % 4 == 3) { strat[16][i + 1] = -1; } else if (i % 4 == 2) { strat[16][i + 1] = -2; } else { strat[16][i + 1] = 18 + i % 2; } } else { strat[16][i + 1] = -2; if (i % 4 == 3) { strat[17][i + 1] = -1; } else if (i % 4 == 2) { strat[17][i + 1] = -2; } else { strat[17][i + 1] = 18 + i % 2; } } } strat[18][0] = strat[19][0] = 0; for (int i = 0; i < N; ++i) { strat[18][i + 1] = -1 - (((i + 1) % 4) < 1); strat[19][i + 1] = -1 - (((i + 1) % 4) < 2); } return strat; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...