제출 #1054234

#제출 시각아이디문제언어결과실행 시간메모리
1054234shiomusubi496죄수들의 도전 (IOI22_prison)C++17
80 / 100
7 ms1216 KiB
#include "prison.h" #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i) #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) using namespace std; using ll = long long; template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; } template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; } std::vector<std::vector<int>> devise_strategy(int N) { vector<int> TH(10); TH[0] = 1; rep (i, 9) TH[i + 1] = TH[i] * 3; vector<vector<int>> res(23, vector<int>(N + 1)); res[0][0] = 0; rep2 (i, 1, N + 1) res[0][i] = i / TH[7] % 3 + 1; rep (i, 7) rep (j, 3) { res[i * 3 + 1 + j][0] = (i + 1) % 2; rep2 (k, 1, N + 1) { if (k / TH[7 - i] % 3 < j) res[i * 3 + 1 + j][k] = -1 - (i + 1) % 2; else if (k / TH[7 - i] % 3 > j) res[i * 3 + 1 + j][k] = -1 - i % 2; else if (i < 6) res[i * 3 + 1 + j][k] = (i + 1) * 3 + 1 + k / TH[6 - i] % 3; else if (i == 6) { if (k % 3 == 0) res[i * 3 + 1 + j][k] = -1 - (i + 1) % 2; else if (k % 3 == 2) res[i * 3 + 1 + j][k] = -1 - i % 2; else res[i * 3 + 1 + j][k] = 22; } } } { res[22][0] = 0; rep2 (k, 1, N + 1) { if (k % 3 == 0) res[22][k] = -1; else if (k % 3 == 2) res[22][k] = -2; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...