Zoj1100 pressure DP + Deep Search

Source: Internet
Author: User

I remember that I was able to solve a problem similar to this kind of problem by using a combination of mathematical methods. Unfortunately, I forgot and couldn't find it. Some people on the Internet also mentioned that I could use a combination of formulas to solve the problem, but no one has done it. They all use the DP method. It is very difficult to make it clear. We recommend two articles.


First look at this roughly: http://blog.csdn.net/crux_d/article/details/2206736

Look at his parsing when you want to implement it in detail: http://blog.csdn.net/yan_____/article/details/8719748


# Include <iostream> # include <cstdio> # include <list> # include <algorithm> # include <cstring> # include <string> # include <queue> # include <stack> # include <map> # include <vector> # include <cmath> # include <memory. h> # include <set> # include <cctype> # define ll long # define ll _ int64 # define EPS 1e-8 # define INF 0 xfffffff // const ll INF = 1ll <<61; using namespace STD; // vector <pair <int, int> G; // typedef pair <int, int> P; // vector <pair <int, int>:: iterator ITER; // Map <LL, int> MP; // Map <LL, int>: iterator P; ll DP [12] [10000]; // Number of placement methods in row I status J int binary [15000] [2]; // [I] [0] indicates the status of the current row, [I] [1] indicates the status of the next row that matches [I] [0]. Vertical placement affects int W, H, CNT; void Init () {CNT = 0; memset (DP, 0, sizeof (DP);} void DFS (int n, int now, int NEX) {If (n> W) return; // There is another N + 2, so it may be greater than W directly without generating a value equal to WIF (n = W) {binary [CNT] [0] = now; binary [CNT ++] [1] = NEX; return;} DFS (n + 2, (now <2) + 3, (NEX <2) + 3 ); DFS (n + 1, (now <1) + 1, NEX <1); DFS (n + 1, now <1, (NEX <1) + 1) ;}int main () {While (scanf ("% d", & W, & H), w + H) {Init (); DFS (0, 0); DP [0] [(1 <W)-1] = 1; // The boundary must be filled with 1for (INT I = 0; I 

Zoj1100 pressure DP + Deep Search

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.