1088: [SCOI2005] Minesweeper Minetime limit:10 Sec Memory limit:162 MB
submit:1635 solved:979
[Submit] [Status] 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
The puzzle: Originally saw minesweeper suddenly like to the big one of the large-scale minesweeper digital map, and then this also to DP to find the type number, Qaq frighten silly (hansbug: Until later saw only two lines = =, and the second line also full empty phile: Oh da, that is not the second kill Hansbug: Beg not despise TT), When you think about it, wouldn't it be just to determine the first two values, then all the back of the most there is a way to display it??? (exclaimed--), so I am hehe (on 1<=n<=10000 This condition is to frighten me to wait for Konjac Konjac or to be used for the obstacle eye? Hmm, hum ^_x)
1var
2I,j,k,l,m,n:longint;
3A,b,c:Array[0..20000] ofLongint;
4functionDoit (x:longint): boolean;
5begin
6 ifX>n Then
7begin
8if(a[x-1]-b[x-2]-b[x-1])=0 ThenExit (True)ElseExit (FALSE);
9End;
Tenif((a[x-1]-b[x-2]-b[x-1]) >=0) and((a[x-1]-b[x-2]-b[x-1]) <=1) Then
Onebegin
Ab[x]:=a[x-1]-b[x-2]-b[x-1];
-Exit (doit (x+1));
-End;
theExit (FALSE);
- End;
-begin
-READLN (n);
+ fori:=1 toN Do
-Read (A[i]);
+readln;k:=0;
A fori:=0 to1 Do
at forj:=0 to 1 Do
-begin
-b[1]:=i;b[2]:=j;
-if(b[1]+b[2]) =a[1] Then
-begin
-ifDoit3) ThenInc (k);
inEnd;
-End;
toWriteln (k);
+ End.
1088: [SCOI2005] Minesweeper Mine