// 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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
516 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
432 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Partially correct |
1 ms |
604 KB |
Output is partially correct |
3 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
4 |
Partially correct |
3 ms |
860 KB |
Output is partially correct |
5 |
Partially correct |
5 ms |
1372 KB |
Output is partially correct |
6 |
Partially correct |
6 ms |
1628 KB |
Output is partially correct |
7 |
Partially correct |
7 ms |
1628 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
11 |
Partially correct |
3 ms |
856 KB |
Output is partially correct |
12 |
Partially correct |
6 ms |
1372 KB |
Output is partially correct |