poj 2311 Cutting Game (SG)】的更多相关文章

题意: 有一张W*H的纸片. 每人每次可以横着撕或者竖着撕,先撕出1*1那一方胜. 数据范围: W and H (2 <= W, H <= 200) 思路: 很好抽象出游戏图的模型,用SG解决.直接看代码. 代码: int dp[maxn][maxn]; int sg(int w,int h){ if(dp[w][h]!=-1) return dp[w][h]; bool g[maxn]; mem(g,false); for(int i=2;i<=w/2;++i) g[sg(i,h)^s…
Cutting Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4806   Accepted: 1760 Description Urej loves to play various types of dull games. He usually asks other people to play with him. He says that playing those games can show his e…
题目链接 #include<iostream> #include<cstdio> #include<cstring> using namespace std; ][]; ]; int get_sg(int n,int m) { ) return sg[n][m]; ;i<=n-i;i++) vis[get_sg(i,m)^get_sg(n-i,m)]=; ;i<=m-i;i++) vis[get_sg(n,i)^get_sg(n,m-i)]=; ; ;i++…
[题目链接] http://poj.org/problem?id=2311 [题目大意] 给出一张n*m的纸,每次可以在一张纸上面切一刀将其分为两半 谁先切出1*1的小纸片谁就赢了, [题解] 如果切出了一张1*n的纸条,那么下一步的人一定可以切出1*1的小纸片, 所以每次切只能切出长宽大于等于2的纸片,如果有人无法做到这一点就输了, 根据这种情况我们用记忆化搜索计算sg函数来得出答案. [代码] #include <cstdio> #include <set> #include…
Cutting Game 题意: 有一张被分成 w*h 的格子的长方形纸张,两人轮流沿着格子的边界水平或垂直切割,将纸张分割成两部分.切割了n次之后就得到了n+1张纸,每次都可以选择切得的某一张纸再进行切割.最先切出只有一个格子的纸张(即有 1*1 格子的)的一方获胜.当双方都采取最优策略时,先手必胜还是必败? 题解: 这题是小白书上的,在取得游戏中必胜策略的最后一题,我照着码一遍就叫了,结果居然T了,,最后发现是cin的问题,然后关下同步就可以a了,但好险用了913ms... 还有初始化mem…
POJ 3253 Fence Repair (优先队列) Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needsN (1 ≤ N ≤ 20,000) planks of wood, each having some integer lengthLi (1 ≤ Li ≤ 50,000) units. He the…
POJ 3669 Meteor Shower(流星雨) Time Limit: 1000MS    Memory Limit: 65536K Description 题目描述 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her sa…
[POJ 3071] Football(DP) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4350   Accepted: 2222 Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In each round of the tournament, all tea…
Poj 3613 Cow Relays (图论) 题目大意 给出一个无向图,T条边,给出N,S,E,求S到E经过N条边的最短路径长度 理论上讲就是给了有n条边限制的最短路 solution 最一开始想到是的去直接统计最短路经过了多少条边,结果,,, 还是太年轻了... 不过,看数据范围只有1000,那么floyd是首选 回顾Floyd算法流程,其中的i到j松弛操作是通过k完成的 那么松弛一次就利用一个k点,我现在要经过n条边,那么松弛n次即可 详细说就是更新一次之后,把f[i][j]拷贝到原来的…
D - Jungle Roads Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1251 Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extr…