제출 #771414

#제출 시각아이디문제언어결과실행 시간메모리
771414PurpleCrayon죄수들의 도전 (IOI22_prison)C++17
56 / 100
11 ms1136 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; #define sz(v) int(v.size()) const int B = 12; vector<vector<int>> devise_strategy(int n) { vector<vector<int>> ans(2 * (B + 1) + 1, vector<int>(n + 1)); for (int i = 0; i < sz(ans); i++) { if (i == 0) { ans[i][0] = 0; int b = 0; for (int j = 1; j <= n; j++) { if ((j >> (B - b)) & 1) { ans[i][j] = 2; } else { ans[i][j] = 1; } } } else { int b = (i - 1) / 2; int last = (i - 1) % 2; if (b % 2 == 0) { ans[i][0] = 1; } else { ans[i][0] = 0; } for (int j = 1; j <= n; j++) { int cur = (j >> (B - b)) & 1; if (cur != last) { if (cur < last) ans[i][j] = -ans[i][0] - 1; else ans[i][j] = -(ans[i][0] ^ 1) - 1; } else { if (B == b) { // unreachable state ans[i][j] = -1; continue; } if ((j >> (B - b - 1)) & 1) { ans[i][j] = 2 * (b + 1) + 2; } else { ans[i][j] = 2 * (b + 1) + 1; } } } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...