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;
int n;
vector<vector<int> > v(39);
void solve0(int i) {
int x = 12 - (i / 3);
v[i][0] = 0;
for (int j = 1; j <= n; j++) v[i][j] = i + 1 + ((j >> x) & 1);
}
void solve1(int i) {
int x = 12 - (i / 3);
v[i][0] = 1;
int nxt = (i + 2 < 39 ? i + 2 : 0);
for (int j = 1; j <= n; j++) v[i][j] = ((j >> x) & 1 ? -1 : nxt);
}
void solve2(int i) {
int x = 12 - (i / 3);
v[i][0] = 1;
int nxt = (i + 1 < 39 ? i + 1 : 0);
for (int j = 1; j <= n; j++) v[i][j] = ((j >> x) & 1 ? nxt : -2);
}
vector<vector<int> > devise_strategy(int N) {
n = N;
for (int i = 0; i < 39; i++) {
v[i].assign(n + 1, 0);
if (i % 3 == 0) solve0(i);
if (i % 3 == 1) solve1(i);
if (i % 3 == 2) solve2(i);
}
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |