[BZOJ1088] [SCOI2005] Minesweeper Mine

Source: Internet
Author: User

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

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.