Submission #627036

#TimeUsernameProblemLanguageResultExecution timeMemory
627036lunchboxPrisoner Challenge (IOI22_prison)C++17
100 / 100
12 ms1420 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; int B[] = {3, 3, 3, 3, 3, 3, 2}; int P[] = {1, 4, 7, 10, 13, 16, 19, 21}; int S[] = {5102, 1700, 566, 188, 62, 20, 6, 2}; vvi f; int slv(int b, int i, int l, int r) { f[i][l] = (b & 1) ? -1 : -2; f[i][r] = (b & 1) ? -2 : -1; if (b == 7) return i; for (int j = 0; j < B[b]; j++) { int l_ = l + 1 + j * S[b + 1]; int r_ = l + (j + 1) * S[b + 1]; int i_ = P[b] + j; slv(b + 1, i_, l_, r_); for (int v = l_; v <= r_; v++) f[i][v] = i_; for (int v = l; v <= l_ - 1; v++) f[i_][v] = (b & 1) ? -2 : -1; for (int v = r_ + 1; v <= r; v++) f[i_][v] = (b & 1) ? -1 : -2; } return i; } vvi devise_strategy(int n) { f.assign(21, vi(5103, 1)); slv(0, 0, 1, 5102); f[0][0] = 1; for (int b = 0, p = 1; b < 7; b++) for (int i = 0; i < B[b]; i++) f[p++][0] = b & 1; for (vi& v : f) v.resize(n + 1); return f; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...