FZU 1686 X-dragon puzzle (repeated DLX coverage)

Source: Internet
Author: User
Tags bitset

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
            

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.