제출 #627250

#제출 시각아이디문제언어결과실행 시간메모리
627250phathnv죄수들의 도전 (IOI22_prison)C++17
100 / 100
10 ms980 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; void gen(int ord, int num, int l, int r, vector<vector<int>> &strat, const vector<int>& a) { if (ord == (int) a.size()) { assert(l + 1 == r); strat[num][0] = ord % 2; strat[num][l] = (ord % 2 == 0? -1 : -2); strat[num][r] = (ord % 2 == 0? -2 : -1); return; } int offset = 1; for (int i = 0; i < ord; ++i) { offset += a[i]; } strat[num][0] = ord % 2; strat[num][l] = (ord % 2 == 0? -1 : -2); strat[num][r] = (ord % 2 == 0? -2 : -1); for (int i = 0; i < a[ord]; ++i) { strat[offset + i][l] = (ord % 2 == 0? -2 : -1); strat[offset + i][r] = (ord % 2 == 0? -1 : -2); } ++l, --r; int len = (r - l + 1) / a[ord]; for (int i = 0; i < a[ord]; ++i) { for (int x = l + len * i; x <= l + len * (i + 1) - 1; ++x) { strat[num][x] = offset + i; } for (int j = 0; j < a[ord]; ++j) { if (i == j) { gen(ord + 1, offset + i, l + len * i, l + len * (i + 1) - 1, strat, a); } else if (j < i) { for (int x = l + len * j; x <= l + len * (j + 1) - 1; ++x) { strat[offset + i][x] = (ord % 2 == 0? -2 : -1); } } else { for (int x = l + len * j; x <= l + len * (j + 1) - 1; ++x) { strat[offset + i][x] = (ord % 2 == 0? -1 : -2); } } } } } vector<vector<int>> genStrat(vector<int> a) { int x = accumulate(a.begin(), a.end(), 0); int n = 2; for (int i = a.size() - 1; i >= 0; --i) { n = n * a[i] + 2; } vector<vector<int>> strat(x + 1, vector<int>(n + 1, 0)); gen(0, 0, 1, n, strat, a); return strat; } vector<vector<int>> devise_strategy(int N) { vector<vector<int>> res = genStrat({3, 3, 3, 3, 2, 2, 2, 2}); for (auto &v : res) { v.resize(N + 1); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...