This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "prison.h"
using namespace std;
using ll = long long;
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(37, vector<int>(n + 1));
ans[0][0] = 1;
for (int i = 1;i <= n;i++) {
ans[0][i] = 36;
}
for (int i = 1;i <= 12;i++) {
int a = i;
ans[i][0] = 2;
for (int j = 1;j <= n;j++) {
if (!(j & (1 << (a - 1)))) ans[i][j] = -2;
else ans[i][j] = 24 + a - 1;
}
}
for (int i = 13;i <= 24;i++) {
int a = i - 12;
ans[i][0] = 2;
for (int j = 1;j <= n;j++) {
if (j & (1 << (a - 1))) ans[i][j] = -1;
else ans[i][j] = 24 + a - 1;
}
}
for (int i = 25;i <= 36;i++) {
int a = i - 24;
ans[i][0] = 1;
for (int j = 1;j <= n;j++) {
if (j & (1 << (a - 1))) ans[i][j] = a;
else ans[i][j] = 12 + a;
}
}
return ans;
}
// int main() {
// int n, a, b;
// cin >> n >> a >> b;
// vector<vector<int>> adj = devise_strategy(n);
// int now = 0;
// int cnt = 0;
// while (now >= 0 && cnt <= 500) {
// cout << now << '\n';
// if (adj[now][0] == 1) {
// now = adj[now][a];
// }
// else {
// now = adj[now][b];
// }
// cnt++;
// }
// cout << cnt << ' ' << now;
// }
/*
// a (1 <= a <= 12)
// - 0 -> start point (check A) go to leftmost bit 36
// - a (check B) if(B don't have ath bit) Answer B
// else write 24 + a - 1
// - 12 + a (check B) if(B have ath bit) Answer A
// else write 24 + a - 1
// - 24 + a (check A) if(A have ath bit) write a-1
// else write 12 + a - 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |