0 for the 1 with the table can not put a 2*2 each time the block can not let the loser
Output Yes if the initiator is winning
Winning state: There is a must-have in the status that can be reached from the current state
The state that can be achieved from the current state is all a winning
Sample Input
4 4
0000
0000
0000
0000
4 4
0000
0010
0100
0000
Sample Output
Yes
No
1# include <iostream>2# include <cstdio>3# include <cstring>4# include <algorithm>5# include <string>6# include <cmath>7# include <queue>8# include <list>9# define LLLong LongTen using namespacestd; One A Charstr[ -][ -]; - intp[ -][ -]; - intn,m; the intDFS () - { - intI,j,flag; -Flag =0; + for(i =0; i < n-1; i + +) - { + for(j =0; J < M1; j + +) A { at if(P[i][j] = =0&&p[i+1][J] = =0&&p[i][j+1] ==0&&p[i+1][j+1] ==0) - { -P[I][J] = p[i+1][J] = p[i][j+1] = p[i+1][j+1] =1; - if(DFS () = =0)//There must be a state of sub-states -Flag =1; -P[I][J] = p[i+1][J] = p[i][j+1] = p[i+1][j+1] =0; in } - } to } + if(flag) - return 1; the Else * return 0; $ }Panax Notoginseng intMain () - { the inti,j; + while(SCANF ("%d%d", &n,&m)! =EOF) A { the for(i =0; I < n; i + +) +scanf"%s", Str[i]); - for(i =0; I < n; i + +) $ { $ for(j =0; J < M; J + +) - { - if(Str[i][j] = ='0') theP[I][J] =0; - ElseWuyiP[I][J] =1; the } - } Wu if(Dfs ()) -printf"yes\n"); About Else $printf"no\n"); - } - return 0; -}
View Code
Hdu 1760 dfs+ Game