Submission #1059133

#TimeUsernameProblemLanguageResultExecution timeMemory
1059133AmirAli_H1Prisoner Challenge (IOI22_prison)C++17
80 / 100
7 ms1628 KiB
// In the name of Allah #include <bits/stdc++.h> #include "prison.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define F first #define S second #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define Mp make_pair #define pb push_back #define endl '\n' #define sep ' ' int n; vector<vector<int>> ans; int get_num(int x, int R) { int T = (7 - R); while (T--) x /= 3; return (x % 3); } int Rt(int x) { if (x == 0) return -1; else return -2; } int Nt(int x) { if (x == 0) return -2; else return -1; } vector<vector<int>> devise_strategy(int N) { n = N; ans.resize(23); for (int i = 0; i < 23; i++) { ans[i].resize(n + 1); for (int j = 0; j <= n; j++) { int x = (i + 2) / 3; if (j == 0) ans[i][j] = (x % 2); else { if (x != 0) { int R1 = (i + 2) % 3, R2 = get_num(j, x - 1); if (x == 8) { if (R2 == 0) ans[i][j] = Rt(ans[i][0]); else ans[i][j] = Nt(ans[i][0]); } else { if (R2 < R1) ans[i][j] = Rt(ans[i][0]); else if (R1 < R2) ans[i][j] = Nt(ans[i][0]); else if (x == 7) { int Rx = get_num(j, x); if (Rx == 0) ans[i][j] = Rt(ans[i][0]); else if (Rx == 2) ans[i][j] = Nt(ans[i][0]); else ans[i][j] = (x * 3 + 1); } else ans[i][j] = (x * 3 + 1) + get_num(j, x); } } else ans[i][j] = (x * 3 + 1) + get_num(j, x); } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...