제출 #802983

#제출 시각아이디문제언어결과실행 시간메모리
802983SlavicG죄수들의 도전 (IOI22_prison)C++17
0 / 100
1 ms852 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define pb push_back int ii = -1; vector<vector<int>> a; vector<int> dp, pp; int rec(int p, int l1, int r1, int l2, int r2, int b) { int idx = ++ii; a[idx][0] = p; for(int i = l1; i <= l2; ++i) a[idx][i] = (!p ? -1 : -2); for(int i = r2; i <= r1; ++i) a[idx][i] = (!p ? -2 : -1); int l = l1 + 1, r = r1 - 1; if(!b) return idx; int jump = dp[b - pp[b]]; for(int i = l; i < r; i += jump) { int child = rec(p ^ 1, l2, r2, i, i + jump - 1, b - pp[b]); for(int j = i; j < i + jump; ++j) a[idx][j] = child; } return idx; } std::vector<std::vector<int>> devise_strategy(int N) { dp.push_back(2); pp.push_back(1); while(dp.back() < N) { int sz = sz(dp); dp.push_back(0); pp.push_back(0); for(int i = 1; i <= sz; ++i) { if(i * dp[sz - i] + 2 > dp.back()) { dp.back() = i * dp[sz - i] + 2; pp.back() = i; } } } int m = sz(dp); a.assign(m, vector<int>(dp.back() + 1)); rec(0, 1, dp.back(), 1, dp.back(), m - 1); for(int i = 0; i < m; ++i) while(sz(a[i]) > N + 1) a[i].pop_back(); return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...