Description
I believe everyone has played the game of minesweeper. There are some thunder in a n*m matrix, you need to find out the ray based on some information. Halloween arrived, "Yu" People have a simple game of minesweeper, the rules of the game and the same as mine, if a lattice does not have thunder, then it is the number of the inside of the grid and its 8 connected to the number of thunder. Now the chessboard is NX2, and the first column contains some grids that are thunder, and the second column has no thunder, such as: Because the first column of thunder may have many options to meet the number of the second column limit, your task is to determine the second column according to the information of the first quagliere how many kinds of placement scheme.
Input
The first behavior n, the second row has n number, in order the number of the second column in the lattice. (1<= N <= 10000)
Output
A number, that is, the number of thunder in the first column.
Sample Input2
1 1Sample Output2
1#include <cstdio>2#include <cstring>3 using namespacestd;4 intf[10010],ans,a[10010],n;5 intjudge () {6 for(intI=2; i<=n;i++){7f[i+1]=a[i]-f[i]-f[i-1];8 if(f[i-1]<0)return 0; 9 }Ten if(a[n]-f[n-1]-f[n]!=0)return 0; One return 1; A } - - intMain () { thescanf"%d",&n); - for(intI=1; i<=n;i++) scanf ("%d",&a[i]); - if(a[1]==0) ans+=judge (); - Else if(a[1]==1) { +f[1]=1; ans+=judge (); -Memset (F,0,sizeof(f)); +f[2]=1; Aans+=judge (); at}Else if(a[1]==2){ -f[1]=f[2]=1; ans+=judge (); - } -printf"%d", ans); -}
"Bzoj 1088" [SCOI2005] Minesweeper Mine