A New Tetris GameTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission (s): 900 Accepted Submission (s ): 404 Problem Description once, Lele and his sister liked it most, and the longest game was Tetris. Gradually, Lele found that playing this game only requires fast hands and almost no brain thinking. So Lele came up with a new method. Lele and her sister took out a rectangular checkerboard, which was unavailable and the rest were available. Lele and his sister took out the square blocks (2*2 square blocks) in the Russian square and put them in turn to the board, the square blocks to be placed cannot be stacked on the unavailable lattice of the checker, or on the already placed square blocks. At the end of the day, whoever can no longer put square blocks will lose. Now, if every time Lele and her sister are very smart, they can put squares according to the optimal strategy, and each time they are put first in the square, can you tell him whether he will win his sister? Input this question contains multiple groups of tests, please process until the end of the file. The first line of each test contains two positive integers N and M (0 <N * M <50), representing the number of rows and columns of the Board respectively. Next there are N rows. Each row has M 0 or 1 numbers representing the entire board. 0 indicates that the position of the board is available. 1 indicates that the position of the board is unavailable. You can assume that the number of 0 in each board is no more than 40. Output for each group of tests, if Lele is sure to win, Output "Yes" in a row; otherwise, Output "No ". Sample Input4 400000000000000004 40000001001000000 Sample OutputYesNo idea: Brute Force
# Include <stdio. h> int n, m; int find (int a [] [50]) {int I, j; for (I = 1; I <n; I ++) for (j = 1; j <m; j ++) {if (a [I] [j] = 0 & a [I-1] [j] = 0 & a [I] [J-1] = 0 & [I-1] [J-1] = 0) {int t [50] [50]; for (int ii = 0; ii <n; ii ++) for (int jj = 0; jj <m; jj ++) t [ii] [jj] = a [ii] [jj]; t [I] [j] = 1; t [I-1] [j] = 1; t [I] [J-1] = 1; t [I-1] [J-1] = 1; if (find (t) = 0) return 1; // note that as long as one successor is satisfied, it will be defeated.} return 0; // all successors will be defeated. It will be defeated.} int main () {int I, j, a [50] [50]; whi Le (scanf ("% d", & n, & m )! = EOF) {for (I = 0; I <n; I ++) for (j = 0; j <m; j ++) scanf ("% 1d ", & a [I] [j]); // printf ("dd"); int ans = find (a); if (ans! = 0) printf ("Yes \ n"); else printf ("No \ n");} return 0 ;}