poj 3575 Crosses and Crosses(SG函数)】的更多相关文章

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…
http://poj.org/problem?id=2960 sg函数几乎是模板题. 调试代码的最大障碍仍然是手残在循环里打错变量名,是时候换个hydra产的机械臂了[超想要.jpg] #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostream> #include<map> using namespace std; ;…
Crosses and Crosses Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3063   Accepted: 1196 Case Time Limit: 2000MS Description The game of Crosses and Crosses is played on the field of 1 × n cells. Two players make moves in turn. Each mov…
题目:在1*n 的棋盘里面,A和B都在里面画叉 , 如果谁可以画了一个叉后,可以连成3个叉,那谁胜利 : 分析: 首先考虑如果我在玩游戏,我最希望对手可以画出-x-x or  -xx-   ,  这种情况 ,也就是说玩家就一定不可画成这样给对手制造机会 :  那可以当成画了一个叉后 就分成了 (x-3) , (x-2-i)  ,两个游戏 ,那我们可以根据SG的性质来解决这种分解游戏的游戏 #include<stdio.h> #include<string.h> //注意 S数组要按…
                  Crosses and Crosses Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4049   Accepted: 1586 Case Time Limit: 2000MS Description The game of Crosses and Crosses is played on the field of 1 × n cells. Two players make moves…
Crosses and Crosses Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 2237 Accepted: 821 Case Time Limit: 2000MS Description The game of Crosses and Crosses is played on the field of 1 × n cells. Two players make moves in turn. Each move the…
博弈论 相当于放了x的位置,左右4格都不能再放x了,谁无处可放就输. n<=2000 直接枚举后继状态,暴力求SG函数即可. 例: 0000000->x..0000 / .x..000 / ..x..00 / 0..x..0 / 00..x.. 记忆化搜索写挂了……还是顺序DP靠谱= =(跟S-Nim类似的写法,暴力求SG函数) Source Code Problem: User: sdfzyhy Memory: 692K Time: 141MS Language: G++ Result: A…
http://poj.org/problem?id=2425 典型的sg函数,建图搜sg函数预处理之后直接求每次游戏的异或和.仍然是因为看不懂题目卡了好久. 这道题大概有两个坑, 1.是搜索的时候vis数组应该在函数内声明(似乎这是我经常在搜索里犯的错误,为了省一点空间整道题都写错了): 2.是n个点的有向无环图边数上限是n^2(re了好久QAQ). 在漫长的查资料过程之后终于大概搞懂了sg函数的原理,愉快.下一篇大概会写一个小结. 代码 #include<cstdio> #include&l…
[题目链接] http://poj.org/problem?id=3537 [题目大意] 在一个1*n的方格纸上下棋,谁先连三子谁就赢了,问必胜的是谁. [题解] 我们发现对于一个n规模的游戏.在i位置下棋就能将游戏拆分为i-3和n-i-2两个游戏 对于可拆分的游戏,其sg函数为拆分后游戏sg值的异或和,因此我们用记忆化搜索来记录sg值. [代码] #include <cstdio> #include <cstring> using namespace std; int n,sg[…
题目链接:http://poj.org/problem?id=2960 题目大意:给定数组S,接下来给出m个游戏局面.游戏局面是一些beads堆,先给出堆数,然后是每一堆中beads的数目.游戏规则是,两个人轮流取beads,每次可以选择一堆,从中取出k个beads,k ∈S,最后不能取的人输. 分析: 取每一堆石子都可以看成是一个单独的游戏,因此,n堆石子就是n个游戏,每个子游戏的状态是其beads的数目,胜负很好判定,求出sg函数即可.最后所有游戏局面的Nim和即为此题的解. 参考代码:(注…