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's here.
, "Yu" People in the country has a simple game of minesweeper, the rules of the game and the same as mine, if a lattice without thunder, then it inside the number
Represents the number of thunder inside the lattice with which it is 8 connected. Now the chessboard is nx2, and some of the squares in the first column are thunder, and the second column has no thunder, such as:
Since the first column of thunder may have multiple scenarios that meet the limits of the number of the second column, your task is to determine how many of the first quagliere are placed according to the information in the second column.
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 Output2HINTSourceSolution
If the first lattice is determined, then the remaining lattice can be calculated, the first lattice only $2$ kind of situation (that is, there is thunder and no thunder), do it all over again
1#include <bits/stdc++.h>2 using namespacestd;3 intg[10005][3];4 intMain ()5 {6 intN, W, ans =0;7 BOOLFlag =true;8CIN >>N;9 for(inti =1; I <= N; ++i)TenCIN >> g[i][2]; Oneg[1][1] =1; A for(inti =2; I <= N; ++i) - { -W = g[i-2][1] + g[i-1][1]; the if(G[i-1][2]-W = =1) -g[i][1] =1; - Else if(! (G[i-1][2] -W)) - Continue; + Else -Flag =false; + } A if(G[n-1][1] + g[n][1]! = g[n][2]) atFlag =false; -Ans + =Flag; -Flag =true; - for(inti =1; I <= N; ++i) -g[i][1] =0; - for(inti =2; I <= N; ++i) in { -W = g[i-2][1] + g[i-1][1]; to if(G[i-1][2]-W = =1) +g[i][1] =1; - Else if(! (G[i-1][2] -W)) the Continue; * Else $Flag =false;Panax Notoginseng } - if(G[n-1][1] + g[n][1]! = g[n][2]) theFlag =false; +Ans + =Flag; Acout << ans <<Endl; the return 0; +}
View Code
[BZOJ1088] [SCOI2005] Minesweeper Mine