제출 #628613

#제출 시각아이디문제언어결과실행 시간메모리
628613tutis죄수들의 도전 (IOI22_prison)C++17
42.50 / 100
19 ms1480 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...