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 "prison.h"
#ifdef NYAOWO
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;
int kth_digit(int x, int b, int k) {
while(k--) x /= b;
return x % b;
}
vector<vector<int>> devise_strategy(int N) {
int BASE = 3;
int LG = 7;
int x = (LG + 1) * BASE + 1;
vector<vector<int>> res(x);
res[0].eb(0);
For(i, 1, N) res[0].eb(kth_digit(i, BASE, LG) + 1);
For(i, 1, x - 1) {
int k = LG - ((i - 1) / BASE);
int dig = (i - 1) % BASE;
if(k % 2) res[i].eb(0);
else res[i].eb(1);
For(num, 1, N) {
int dig2 = kth_digit(num, BASE, k);
if(dig2 > dig) {
if(k % 2) res[i].eb(-2);
else res[i].eb(-1);
} else if(dig2 < dig) {
if(k % 2) res[i].eb(-1);
else res[i].eb(-2);
} else if(k == 0) {
res[i].eb(0);
} else {
res[i].eb(i - dig + BASE + kth_digit(num, BASE, k - 1));
}
}
}
return res;
}
/*
3
1 2
1 3
2 1
2 3
3 1
3 2
-1
A
A
B
A
B
B
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |