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;
vector<vector<int>> ans;
const int MAX = 21;
const int C = 7;
int a[C] = {2, 3, 3, 3, 3, 3, 3};
int p[C] = {18, 15, 12, 9, 6, 3, 0};
void solve(int L, int R, int ai, int ID){
ans[ID][0] = ai % 2 != 0;
if(R - L < 2) return;
ans[ID][L] = ai % 2 != 0 ? -2 : -1;
ans[ID][R - 1] = ai % 2 != 0 ? -1 : -2;
L++; R--;
if(L >= R) return;
assert(ai != -1);
vector<int> M;
M.push_back(L);
for(int i = 1; i < a[ai]; i++){
M.push_back((L * (a[ai] - i) + R * i) / a[ai]);
}
M.push_back(R);
for(int i = 0; i < a[ai]; i++){
for(int j = M[i]; j < M[i + 1]; j++){
ans[ID][j] = p[ai] + i + 1;
}
}
for(int i = 0; i < a[ai]; i++){
for(int j = L - 1; j <= M[i]; j++){
ans[p[ai] + i + 1][j] = ai % 2 != 0 ? -1 : -2;
}
solve(M[i], M[i + 1], ai - 1, p[ai] + i + 1);
for(int j = M[i + 1]; j < R + 1; j++){
ans[p[ai] + i + 1][j] = ai % 2 != 0 ? -2 : -1;
}
}
}
vector<vector<int>> devise_strategy(int N) {
ans = vector<vector<int>>(MAX, vector<int>(N + 1));
solve(1, N + 1, C - 1, 0);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |