n hdu 1760 [SG博弈]二维状态
2013-04-14 22:15
316 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1760
题意:出处/article/2027651.html
题意:给你一个n*m的矩形,0表示空着的,1反之,现在两个人轮流放2*2的矩形,谁不能放了,谁就输了。
找sg值,可以选择暴力,也可以利用sg值的特点简化。
暴力就跟取石子一样,没什么差别,DFS搞定。把矩阵看成一个字符串,字符串就是一个状态。
其实我们也可以不暴力求sg值,因为只要当前状态能到达一个sg值为0的点,当前状态就是必胜点。
若当前点到达的所有状态都是必胜的,那么当前点就是必败点。所以当我们到达必胜点时,就必须转换当前状态继续递归找sg值。
法一、暴力找sg值:
http://hi.baidu.com/isaacpei/item/9bd8202e6aa236f950fd87ef
表示还在理解中。。。。n
View Code
题意:出处/article/2027651.html
题意:给你一个n*m的矩形,0表示空着的,1反之,现在两个人轮流放2*2的矩形,谁不能放了,谁就输了。
找sg值,可以选择暴力,也可以利用sg值的特点简化。
暴力就跟取石子一样,没什么差别,DFS搞定。把矩阵看成一个字符串,字符串就是一个状态。
其实我们也可以不暴力求sg值,因为只要当前状态能到达一个sg值为0的点,当前状态就是必胜点。
若当前点到达的所有状态都是必胜的,那么当前点就是必败点。所以当我们到达必胜点时,就必须转换当前状态继续递归找sg值。
法一、暴力找sg值:
http://hi.baidu.com/isaacpei/item/9bd8202e6aa236f950fd87ef
表示还在理解中。。。。n
View Code
// I'm lanjiangzhou //C #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> #include <time.h> //C++ #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <cctype> #include <stack> #include <string> #include <list> #include <queue> #include <map> #include <vector> #include <deque> #include <set> using namespace std; //*************************OUTPUT************************* #ifdef WIN32 #define INT64 "%I64d" #define UINT64 "%I64u" #else #define INT64 "%lld" #define UINT64 "%llu" #endif //**************************CONSTANT*********************** #define INF 0x3f3f3f3f // aply for the memory of the stack //#pragma comment (linker, "/STACK:1024000000,1024000000") //end int n,m; const int maxn =110; char s[maxn][maxn]; int a[maxn][maxn]; int mm[maxn][maxn]; int findset(int mm[maxn][maxn]){ for(int i=0;i<n-1;i++){ for(int j=0;j<m-1;j++){ if(mm[i][j]+mm[i+1][j]+mm[i][j+1]+mm[i+1][j+1]==0){ int tt[maxn][maxn]; for(int x=0;x<n;x++){ for(int y=0;y<m;y++){ tt[x][y]=mm[x][y]; } } tt[i][j]=tt[i+1][j]=tt[i][j+1]=tt[i+1][j+1]=1; if(findset(tt)==0) return 1; } } } return 0; } int main(){ while(scanf("%d%d",&n,&m)!=EOF){ //getchar(); for(int i=0;i<n;i++){ scanf("%s",s[i]); for(int j=0;j<m;j++) a[i][j]=s[i][j]-'0'; } if(findset(a)) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- HDOJ1760[SG博弈]二维状态
- n hdu 1760 [SG博弈]二维状态
- hdu 4678 Mine(博弈SG,4级)
- 博弈问题及SG值
- 尼姆博弈的SG值计算简单模板
- HDU 1517 A Multiplication Game (博弈-求sg)
- HDOJ 题目1566&题目1544 S-Nim(sg博弈模板)
- 一维数组建模表示二维的棋盘状态
- LA 3668 A Funny Stone Game(博弈,SG定理)
- HDU3904【有向无环树形图SG博弈】
- POJ2599 [树形SG博弈]记忆化
- HDOJ 1079 && POJ 1082 Calendar Game (博弈: 暴力枚举所有状态的P\N)
- hdu 4778 Gems Fight! 博弈+状态dp+搜索
- hdu 4678 Mine(博弈SG,4级)
- hdu 1847 还是不知道sg,不过暴力出各个状态
- UVALive-7278 - Game of Cards【博弈】【sg定理】
- 【HDU1079】Calendar Game(博弈,PN状态枚举)
- hdu 1848 sg博弈模版题
- hdu 5724 Chess 博弈sg+状态压缩
- HDU - 1847 Good Luck in CET-4 Everybody! 简单博弈 SG打表