Hdoj topic 1760 A New Tetris Game (DFS, game)

Source: Internet
Author: User

A New Tetris GameTime limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1212 Accepted Submission (s): 582


Problem description once, Lele and his sister favorite, play the longest game is the Tetris (Tetris).
Gradually, Lele found that playing this game only requires deft on hand, almost without thinking through the brain.
So, Lele came up with a new play.

Lele and sister first took out a rectangular chessboard, the chessboard some of the grid is not available, the rest is usable. Lele and elder sister take out Tetris Square square box (size is 2*2 square square box), take turns to put in the chessboard, notice is, put in the square block can not be stacked on the board is not available on the grid, also can not be stacked on the square square that already put.
In the end, no one can put the square box, who loses.

Now, assuming every time Lele and sister are very smart, can be the best strategy to put a square, and each time is lele first put a square, can you tell him whether he will win sister?

Input This topic contains multiple sets of tests, please handle to the end of the file.
The first row of each group of tests contains two positive integers N and M (0<N*M<50) representing the number of rows and columns of the chessboard, respectively.
Next there are n rows, each with a number of M 0 or 1 representing the entire board.
where 0 is representative of the chessboard that location is available, and 1 is the chessboard that is not available for the location

You can assume that there are no more than 40 0 in each board.
Output for each set of tests, if the Lele has the certainty to win, in a row of "Yes", or Output "No".

Sample Input
4 400000000000000004 40000001001000000

Sample Output
YesNo

Authorlinle
Source2007 Provincial Training Team Practice (6) _linle session
Recommendlcy | We have carefully selected several similar problems for you:1404 1729 1809 3094 2580AC Code
#include <stdio.h> #include <string.h> #include <stdlib.h>char map[55][55];int n,m;int dfs (char map[ 55][55]) {char temp[55][55];int i,j,x,y;for (i=1;i<n;i++) {for (j=1;j<m;j++) {if (map[i][j]== ' 0 ' &&map[ i-1][j]== ' 0 ' &&map[i][j-1]== ' 0 ' &&map[i-1][j-1]== ' 0 ') {/*for (k=0;k<n;k++) {strcpy (map[k],temp[k ]);} */for (x=0;x<n;x++) {for (y=0;y<m;y++) temp[x][y]=map[x][y];} temp[i][j]=temp[i-1][j]=temp[i-1][j-1]=temp[i][j-1]= ' 1 '; if (Dfs (temp) ==0)//can lead to a certain point is the victory Point return 1;}} Return 0;//can only lead to the Victory point is a must defeat}int main () {//int n,m;while (scanf ("%d%d", &n,&m)!=eof) {int i,j;for (i=0;i<n;i++) {/ /for (j=0;j<m;j++)//{scanf ("%s", &map[i]),//}}if (DFS (map)) printf ("yes\n"); elseprintf ("no\n");}}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hdoj topic 1760 A New Tetris Game (DFS, game)

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.