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;
/*
void print_strat(vector<vector<int>> s) {
for (int i = 0; i < int(s.size()); i++) {
int counter = i >> 1;
int other = i & 1;
int bag = s[i][0];
for (int j = 1; j <= N; j++) {
}
}
}*/
vector<vector<int>> devise_strategy(int N) {
int n = 13*2 - 2;
vector<vector<int>> s(n);
for (int i = 2; i < n; i++) {
//printf("i: %d\n", i);
s[i].resize(N+1);
int counter = i >> 1;
int other = i & 1;
int bag = counter % 2;
s[i][0] = bag;
//printf("i: %d counter: %d other: %d bag: %d\n", i, counter, other, bag);
for (int j = 1; j <= N; j++) {
if (counter == 11) {
int bit = (j & (1 << counter)) > 0;
if (bit) {
int lowest = !bag;
s[i][j] = -(lowest+1);
continue;
}
}
//if (j != 4090 && j != 4096) continue;
//printf("j: %d ", j);
int bit = (j & (1 << counter)) > 0;
if (bit == other) {
if (counter == 1) {
int last_bit = j & 1;
int lowest = bag;
if (last_bit == 1) lowest = !bag;
s[i][j] = -(lowest+1);
//printf("lowest: %d\n", lowest);
} else {
int new_counter = counter-1;
int new_other = (j & (1 << new_counter)) > 0;
s[i][j] = (new_counter << 1) + new_other;
//printf("counter: %d other: %d\n", new_counter, new_other);
}
} else {
int lowest = bag;
if (other < bit) lowest = !lowest;
s[i][j] = -(lowest+1);
//printf("lowest: %d\n", lowest);
}
}
}
s[0].resize(N+1);
s[1].resize(N+1);
int counter = 12;
int bag = !(counter % 2);
s[0][0] = bag;
for (int j = 1; j <= N; j++) {
int bit = (j & (1 << counter)) > 0;
if (bit) {
s[0][j] = 1;
} else {
int new_counter = counter-1;
int next_bit = (j & (1 << new_counter)) > 0;
s[0][j] = (new_counter << 1) + next_bit;
}
}
s[1][0] = !bag;
for (int j = 1; j <= N; j++) {
int bit = (j & (1 << counter)) > 0;
if (bit) {
int new_counter = counter-2;
int next_bit = (j & (1 << new_counter)) > 0;
s[1][j] = (new_counter << 1) + next_bit;
} else {
int lowest = !bag;
s[1][j] = -(lowest+1);
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |