1088: [SCOI2005] Minesweeper Mine

Source: Internet
Author: User

1088: [SCOI2005] Minesweeper mine time limit: ten Sec Memory Limit: 162 MB
Submit: 1676 Solved: 1002
[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 Output2

Simulation questions.


As long as the first lattice has no thunder, according to A[1], you can get a second lattice has no thunder, according to A[3], know the third lattice has no thunder .... And so on, to see if there is a contradiction.


The answer can only be 0, 1, 2.


#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include < Algorithm> #define INF 0x3f3f3f3fusing namespace Std;int a[10005],f[10005],n,ans=0;int judge () {for (int i=2;i<n;i + +) {f[i+1]=a[i]-f[i]-f[i-1];if (f[i+1]!=0&&f[i+1]!=1) return 0;} return f[n]+f[n-1]==a[n];} int main () {        scanf ("%d", &n), for (int i=1;i<=n;i++) scanf ("%d", &a[i]), if (a[1]==0) Ans+=judge (); else if ( A[1]==1)     {F[1]=1,f[2]=0,ans+=judge (); F[1]=0,f[2]=1,ans+=judge ();     } else F[1]=1,f[2]=1,ans+=judge (); Cout<<ans<<endl;return 0;}




1088: [SCOI2005] Minesweeper Mine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.