Enumerate the top two bits and push the remaining
1088: [SCOI2005] Minesweeper mine time limit: ten Sec Memory Limit: 162 MB
Submit: 1832 Solved: 1090
[Submit] [Status] [Discuss] 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 Output2HINT
Source
/* ***********************************************author:ckbosscreated time:2015 April 28 Tuesday 20:49 17 seconds file Name : bzoj1088.cpp************************************************ * * #include <iostream> #include <cstdio># Include <cstring> #include <algorithm> #include <string> #include <cmath> #include <cstdlib > #include <vector> #include <queue> #include <set> #include <map>using namespace Std;const int Maxn=11000;int N,a[maxn],b[maxn],ans;int Main () {//freopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w", stdout), scanf ("%d", &n), for (int i=1;i<=n;i++) scanf ("%d", a+i), if (n==1) {if "a[1]< =0) puts ("1"); Else puts ("0"); return 0;} if (n==2) {if (a[1]==0&&a[2]==0) puts ("1"); else if ((a[1]==1&&a[2]==0) | | (a[1]==0&&a[2]==1)) Puts ("2"), else if (a[1]==2&&a[2]==2) puts ("1"), Else puts ("0"); return 0;} BOOL Flag;if (a[1]==0) {///0,0memset (b,0,sizeof (b)); Flag=true;int presum=0;for (int I=3;I<=N&&Amp;flag;i++) {int next=a[i-1]-presum;if (next==1| | next==0) {B[i]=next;} else flag=false;presum-=b[i-2];p resum+=next;} if (B[n]+b[n-1]!=a[n]) flag=false;if (flag) ans++;} if (a[1]==1) {//0,1flag=true;int Presum=1;memset (b,0,sizeof (b)); b[2]=1;for (int i=3;i<=n&&flag;i++) {int Next=a[i-1]-presum;if (next==1| | next==0) {B[i]=next;} else flag=false;presum-=b[i-2];p resum+=next;} if (B[n]+b[n-1]!=a[n]) flag=false;if (flag) ans++;///1,0flag=true;presum=1;memset (b,0,sizeof (b)); b[1]=1;for (int i=3;i<=n&&flag;i++) {int next=a[i-1]-presum;if (next==1| | next==0) {B[i]=next;} else flag=false;presum-=b[i-2];p resum+=next;} if (B[n]+b[n-1]!=a[n]) flag=false;if (flag) ans++;} if (a[1]==2) {//1,1memset (b,0,sizeof (b)); B[1]=b[2]=1;flag=true;int presum=2;for (int i=3;i<=n&&flag;i++) {int next=a[i-1]-presum;if (next==1| | next==0) {B[i]=next;} else flag=false;presum-=b[i-2];p resum+=next;} if (B[n]+b[n-1]!=a[n]) flag=false;if (flag) ans++;} printf ("%d\n", ans); return 0;}
Bzoj 1088: [SCOI2005] Minesweeper Mine enumeration