Hdu 3001 (solid-pressure dp + tri-hexadecimal)
Whether it is a few hexadecimal notation, it uses a logical concept. (The last hexadecimal notation was used to convert multi-dimensional data) the core idea is TSP. The Preprocessing here is clever, and the modulo vis [] [] on each bit in each state is calculated.
TSP: the optimal solution ending with j in the I state of dp [I] [j. Both types of transfer are supported: I am for everyone and everyone is for me.
# Include
# Include
# Include
# Include # define maxn 60000 # define inf 0x3f3f3f3fconst double eps = 1e-8; using namespace std; int dp [maxn] [12]; int maps [13] [12]; int vis [maxn] [12]; int state [12]; int n, m; void init () {state [0] = 1; for (int I = 1; I <11; I ++) state [I] = state [I-1] * 3; for (int I = 0; I <= state [10]; I ++) {int x = I; for (int j = 0; j <10; j ++) vis [I] [j] = x % 3, x/= 3 ;}} int main () {// freopen ("in.txt", "r", stdin); while (~ Scanf ("% d", & n, & m) {init (); memset (maps, 0x3f, sizeof (maps); for (int I = 0; I