FZU 1686 X-dragon puzzle (repeated DLX coverage)
DLX practice: Use the number of monsters p as M. Because Emily's attack range is n1 * m1, there will be n * m in a large range.
N1 * m1, so n * m is used as N. Then how is the bool value determined. N1 * m1 blocks of monsters in the region
The number of small regions and monsters should be 1. The following is the minimum value for DLX.
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
Using namespace std; # define REPF (I, a, B) for (int I = a; I <= B; ++ I) # define REP (I, n) for (int I = 0; I <n; ++ I) # define CLEAR (a, x) memset (a, x, sizeof a) typedef long LL; typedef pair
Pil; const int maxn = 15*15 + 10; const int maxnnode = maxn * maxn; const int mod = 1000000007; struct DLX {int n, m, size; int U [maxnnode], D [maxnnode], L [maxnnode], R [maxnnode], Row [maxnnode], Col [maxnnode]; int H [maxn], S [maxn]; // H [I] location, S [I] Count int ansd; void init (int a, int B) {n = a; m = B; REPF (I, 0, m) {S [I] = 0; U [I] = D [I] = I; L [I] = I-1; R [I] = I + 1;} R [m] = 0; L [0] = m; size = m; REPF (I, 1, n) H [I] =-1;} void link (int r, int c ){ ++ S [Col [++ size] = c]; Row [size] = r; D [size] = D [c]; U [D [c] = size; U [size] = c; D [c] = size; if (H [r] <0) H [r] = L [size] = R [size] = size; else {R [size] = R [H [r]; L [R [H [r] = size; L [size] = H [r]; R [H [r] = size ;}} void remove (int c) {for (int I = D [c]; I! = C; I = D [I]) L [R [I] = L [I], R [L [I] = R [I];} void resume (int c) {for (int I = U [c]; I! = C; I = U [I]) L [R [I] = R [L [I] = I;} bool v [maxn]; int f () {int ret = 0; for (int c = R [0]; c! = 0; c = R [c]) v [c] = true; for (int c = R [0]; c! = 0; c = R [c]) if (v [c]) {ret ++; v [c] = false; for (int I = D [c]; i! = C; I = D [I]) for (int j = R [I]; j! = I; j = R [j]) v [Col [j] = false;} return ret;} void Dance (int d) {if (d + f ()> = ansd) return; if (R [0] = 0) {if (d