POJ 1739 Tony ' s Tour plug DP template problem

Source: Internet
Author: User

Test instructions

For a maze, find the number of paths to the lower-left corner to the lower-right corner.

Analysis:

Plug DP template problem, it is recommended to look at CDQ's paper and then look at the code, this code in the template based on a slight change. Paper Address http://wenku.baidu.com/view/ed2b3e23482fb4daa58d4b74.html

Code:

#include <iostream>using namespace std;const int maxd=16;const int hash=10007;const int state=1000024;int N,M;int M Aze[maxd][maxd];int code[maxd];int ch[maxd];struct hashmap{int head[hash],next[state],size;long Long state[STATE],f[ State];void init () {Size=0;f[0]=0;memset (head,-1,sizeof (Head));} void push (long long st,long long ans) {int h=st%hash;for (int i=head[h];i!=-1;i=next[i]) if (state[i]==st) {F[i]+=ans; return;} state[size]=st;f[size]=ans;next[size]=head[h];head[h]=size++;}} Hm[2];void decode (int *code,int M,long long st) {for (int i=m;i>=0;--i) {code[i]=st&7;st>>=3;}} Long long encode (int *code,int m) {int cnt=1;memset (ch,-1,sizeof (CH)); Long long st=0;ch[0]=0;for (int i=0;i<=m;++i) { if (ch[code[i]]==-1) ch[code[i]]=cnt++;code[i]=ch[code[i]];st<<=3;st|=code[i];} Return St;} void Shift (int *code,int m) {for (int i=m;i>0;--i) code[i]=code[i-1];code[0]=0;} void Init () {char str[20];memset (maze,0,sizeof (Maze)); for (int i=1;i<=n;++i) {scanf ('%s ', str); for (int j=0;j<m;+ +J)if (str[j]== '. ') Maze[i][j+1]=1;}} void Dpblank (int i,int j,int cur) {int k,left,up;for (k=0;k


POJ 1739 Tony ' s Tour plug DP template problem

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.