제출 #627337

#제출 시각아이디문제언어결과실행 시간메모리
627337Lam_lai_cuoc_doi죄수들의 도전 (IOI22_prison)C++17
65 / 100
73 ms98328 KiB
#include "prison.h" #include <vector> #include <algorithm> using namespace std; constexpr int N = 5005; vector<vector<int>> a; int n; bool ck[N]; #define bit(i, x) (((x) >> (i)) & 1) void Recursive(int v) { if (ck[v]) return; ck[v] = 1; if (v == 0) { a[v][0] = 0; for (int i = 1; i <= n; ++i) a[v][i] = 11 + (bit(12, i) * 12) + 1; for (int i = 1; i <= n; ++i) if (a[v][i] > 0) Recursive(a[v][i]); return; } --v; int number, state; if (v >= 12) { state = 1; number = v - 12; } else { state = 0; number = v; } ++number; ++v; if (!(number & 1)) { a[v][0] = 1; for (int i = 1; i <= n; ++i) if (bit(number, i) < state) a[v][i] = -2; else if (bit(number, i) > state) a[v][i] = -1; else a[v][i] = number - 1 + (bit(number - 1, i) * 12); for (int i = 1; i <= n; ++i) if (a[v][i] > 0) Recursive(a[v][i]); } else { a[v][0] = 0; for (int i = 1; i <= n; ++i) if (bit(number, i) < state) a[v][i] = -1; else if (bit(number, i) > state) a[v][i] = -2; else { if (number == 1) { if (bit(0, i)) a[v][i] = -2; else a[v][i] = -1; } else a[v][i] = number - 1 + (bit(number - 1, i) * 12); } for (int i = 1; i <= n; ++i) if (a[v][i] > 0) Recursive(a[v][i]); } } std::vector<std::vector<int>> devise_strategy(int m) { n = m; a.resize(5000, vector<int>(n + 1, 0)); Recursive(0); while (!ck[a.size() - 1]) a.pop_back(); return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...