제출 #802850

#제출 시각아이디문제언어결과실행 시간메모리
802850SlavicG죄수들의 도전 (IOI22_prison)C++17
0 / 100
6 ms724 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define pb push_back int n; vector<vector<int>> st; void rec(int idx, vector<int> elements) { if(elements.empty()) return; while(sz(st) <= idx) st.pb(vector<int>(n + 1)); int p = ((idx + 2) / 3) % 2; st[idx][0] = p; vector<int> A, B, C; for(int j = 1; j <= n; ++j) { if(j > elements.back()) st[idx][j] = (!p ? -2 : -1); if(j < elements[0]) st[idx][j] = (!p ? -1 : -2); } st[idx][elements[0]] = (!p ? -1 : -2); st[idx][elements.back()] = (!p ? -2 : -1); elements.erase(elements.begin()); if(sz(elements)) elements.pop_back(); for(int i = 0; i < sz(elements) / 3; ++i) A.push_back(elements[i]); for(int i = sz(elements) / 3; i < sz(elements) / 3 * 2; ++i) B.push_back(elements[i]); for(int i = sz(elements) / 3 * 2; i < sz(elements); ++i) C.push_back(elements[i]); //if(sz(C) > sz(A)) swap(A, C); int pp = (idx + 2) / 3 * 3; for(auto x: A) st[idx][x] = pp + 1; for(auto x: B) st[idx][x] = pp + 2; for(auto x: C) st[idx][x] = pp + 3; rec(pp + 1, A); rec(pp + 2, B); rec(pp + 3, C); } std::vector<std::vector<int>> devise_strategy(int N) { n = N; vector<int> elements(N); iota(elements.begin(), elements.end(), 1); rec(0, elements); return st; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...