Poj 3254 Corn Fields, status compression DP

Source: Internet
Author: User

Poj 3254 Corn Fields, status compression DP

Question Link

Question:

There are many grids in a matrix. Each grid has two statuses: grazing and not grazing. grazing can be expressed as 1. Otherwise, 0 is used to show cattle in this farm, two adjacent squares must not be placed at the same time, that is, the ox and the ox cannot be adjacent. Ask how many cow solutions are available (not a single cow is also a solution)



State [I] indicates a solution that ensures non-adjacent rows.


Status: dp [I] [state [j] Number of solutions that meet the conditions in row I when the status is state [j]

State Transfer: dp [I] [state [j] = Sigma dp [I-1] [state '] (state' is all States that meet the condition)


Nclude
 
  
# Include
  
   
# Include
   
    
# Define deusing namespace std; const int mod = 100000000; int state [1 <13], cnt; // for a row, ensure that the non-adjacent scheme int dp [20] [1 <13]; int cur [20]; // The value of cur [I] in the binary form 0 indicates that it can be put, 1 indicates that it cannot be placed. Int main () {int n, m, I, j, k; scanf ("% d", & n, & m); int M = 1 <
    
     

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.