Hdu 1760 dfs+ Game

Source: Internet
Author: User

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

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.