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 lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
vector<vector<int> > strat;
int tam,a,num,ant,yo,otro;
std::vector<std::vector<int>> devise_strategy(int N) {
//cambiar para futuras soluciones
tam = 25;
strat.resize(tam);
rep(i,0,tam-1) strat[i].resize(N+1);
//definir la bolsa en la que van a buscar
strat[0][0] = 0;
a = 1;
for(int i = 1; i < 24; i+=2) {
strat[i][0] = a;
strat[i+1][0] = a;
a ^= 1;
}
lli pot = 12;
yo = -1;
otro = -2;
//empezado por el cero
num = 1<<pot;
rep(i,1,N) {
if (i&num) strat[0][i] = 1;
else strat[0][i] = 2;
}
//llenar la tabla de manera normal
rep(i,1,22) {
if (i&1) {
pot--;
swap(yo,otro);
}
num = 1<<pot;
ant = num*2;
rep(j,1,N) {
if ((j&ant) && (i%2) == 0) {strat[i][j] = otro; continue;}
if (!(j&ant) && (i%2) == 1) {strat[i][j] = yo; continue;}
a = num&j;
if (a) strat[i][j] = i+1;
else strat[i][j] = i+2;
}
}
//chcear lo de el caso especial, ultimo bit forzoso es diferente
pot--;
swap(otro,yo);
rep(i,23,24) {
num = 1<<pot;
ant = num*2;
rep(j,1,N) {
if ((j&ant) && (i%2) == 0) {strat[i][j] = otro; continue;}
if (!(j&ant) && (i%2) == 1) {strat[i][j] = yo; continue;}
if (j&1) strat[i][j] = otro;
else strat[i][j] = yo;
}
}
return strat;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |