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"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll int, ll int>
#define ff first
#define ss second
#define pb push_back
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ret;
const vector<int> go5 = {1, 5, 25, 125, 625, 3125, 15625};
int x = 35;
ret.resize(x + 1);
for (int i = 0; i <= x; i++) ret[i].resize(n + 1);
// write 0
ret[0][0] = 0;
for (int i = 1; i <= n; i++) {
ret[0][i] = 25 + (i / go5[5]) + 1;
}
// write 1-30
for (int i = 1; i <= 30; i++) {
int bitpos = (i - 1) / 5, bitval = (i - 1) % 5;
ret[i][0] = 1;
for (int j = 1; j <= n; j++) {
int retval = j % go5[bitpos + 1] / go5[bitpos];
if (bitval < retval) ret[i][j] = -1;
else if (bitval > retval) ret[i][j] = -2;
else ret[i][j] = 30 + bitpos;
}
}
// write 31-35
for (int i = 31; i <= 35; i++) {
int bitpos = (i - 31);
ret[i][0] = 0;
for (int j = 1; j <= n; j++) {
ret[i][j] = bitpos * 5 + (j % go5[bitpos + 1] / go5[bitpos]) + 1;
}
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |