제출 #666231

#제출 시각아이디문제언어결과실행 시간메모리
666231peijar죄수들의 도전 (IOI22_prison)C++17
56 / 100
13 ms1140 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> devise_strategy(int N) { int nbBits = log2(N - 1) + 1; int k = 2 * nbBits + 1; vector<vector<int>> strategy(k, vector<int>(N + 1)); for (int i = 0; i < k; ++i) { if (i == 0) { strategy[i][0] = !((nbBits - 1) % 2); for (int j = 0; j < N; ++j) { if ((1 << (nbBits - 1)) & j) strategy[i][j + 1] = nbBits + 1 + (nbBits - 1); else strategy[i][j + 1] = 1 + (nbBits - 1); } } else if (i <= 2 * nbBits) { int bit = i <= nbBits ? i - 1 : i - nbBits - 1; int big = i > nbBits; strategy[i][0] = bit % 2; for (int j = 0; j < N; ++j) { if (big != !!((1 << bit) & j)) { if (big) strategy[i][j + 1] = -1 - bit % 2; else strategy[i][j + 1] = -2 + bit % 2; } else { if (bit == 0) strategy[i][j + 1] = 0; else { if ((1 << (bit - 1)) & j) strategy[i][j + 1] = nbBits + 1 + bit - 1; else strategy[i][j + 1] = 1 + bit - 1; } } } } } return strategy; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...