Submission #628615

#TimeUsernameProblemLanguageResultExecution timeMemory
628615tutisPrisoner Challenge (IOI22_prison)C++17
0 / 100
1 ms212 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; std::vector<std::vector<int>> devise_strategy(int N) { vector<vector<int>>ret; vector<pair<int, int>>S = {{1, N}}; vector<pair<int, int>>S_; while (!S.empty()) { S_ = {}; int x = (int)ret.size(); ret.push_back(vector<int>(N + 1, 0)); ret.push_back(vector<int>(N + 1, 0)); ret.push_back(vector<int>(N + 1, 0)); vector<int>&v = ret[x]; vector<int>&v1 = ret[x + 1]; vector<int>&v2 = ret[x + 2]; v[0] = 0; v2[0] = 1; v1[0] = 1; for (int i = 0; i < (int)S.size(); i++) { int lo = S[i].first; int hi = S[i].second; v[lo] = -1; v[hi] = -2; v1[lo] = -2; v1[hi] = -1; v2[lo] = -2; v2[hi] = -1; lo++; hi--; if (lo <= hi) { int m = (lo + hi) / 2; if (lo < m) S_.push_back({lo, m}); for (int i = lo; i <= m; i++) { v[i] = x + 1; v1[i] = x + 3; v2[i] = -2; } if (m + 1 < hi) S_.push_back({m + 1, hi}); for (int i = m + 1; i <= hi; i++) { v[i] = x + 2; v2[i] = x + 3; v1[i] = -1; } } } S = S_; } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...