Test instructions: 3 * n Lattice there are some points that are bad with 1x1 and 1x2 brick paving how many ways
The puzzle: Re-learn the contour line is very comfortable to write
#include <bits/stdc++.h>using namespaceStd;typedefLong Longll;intN, M;intvis[ -][5];ll dp[ -][1<<3];voidDfsintNumintIintStateintNEX) { if(num = =3) {Dp[i+1][nex] + =Dp[i][state]; return; } if(Vis[i][num +1] || (State & (1<< num))) DFS (num +1, I, State, NEX); Else{dfs (num+1, I, State, NEX);//Fill 1x1 if(!vis[i +1][num +1] &&! (Nex & (1<<num))) DFS (Num+1, I, state, NEX | (1<< num));//fill the 1x2 with a vertical if(num +2<=3&&!vis[i][num +2] &&! (State & (1<< (num +1))) DFS (Num+2, I, State, NEX);//cross-fill the 1x2 }}intMain () {scanf ("%d%d", &n, &m); for(inti =1; I <= m; i++) { Doublex, y; scanf ("%LF%LF", &x, &y); vis[(int) x +1][(int) y +1] =1; } dp[1][0] =1LL; for(inti =1; I <= N; i++) for(intSt =0; St <8; st++) if(Dp[i][st] >0) { BOOLf =true; for(intK =0; K <3; k++) { if(St & (1<< k) && Vis[i][k +1]) {f=false; Break; } } if(!f)Continue; DFS (0, I, St,0); } printf ("%lld\n", Dp[n +1][0]); return 0;}
View Code
gym100825g. Tray Bien (Contour line DP)