题意: 给1*n的格子,轮流在上面叉叉,最先画得3个连续叉叉的赢.问先手必胜还是必败. 分析: 求状态的grundy值(也就是sg值),详细怎么求详见代码.为什么这么求要自己想的,仅仅可意会(别人都说去看game theory,呵呵). 代码: //poj 3537 //sep9 #include <iostream> #include <set> using namespace std; int grundy[2048]; int h[2048]; int get_grundy(…
博弈论 相当于放了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…
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…
                  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: 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…
Crosses and Crosses poj-3537 题目大意:给定一个1*n的网格,每次往格子内填一个$\times$,连续的三个即可获胜. 注释:$1\le n\le 2000$. 想法:我们先尝试往里面填一个$\times$. 我们发现对于先手和后手来讲,与那个$\times$相邻的格子都不能动. 所以就相当于整个游戏被分成了3个游戏,中间的是一个$\times$和两个空格. 发现中间的游戏先手必败,故中间的游戏的SG为0. 即:只需要求左右的SG值,爆搜即可. 最后,附上丑陋的代码.…
选修了人工智能课程,老师布置了调研任务:Grundy,开始看了一些资料并没有看懂. 后来找到了一篇文,写的很棒,里面有好多博弈相关的问题与分析,分享出来给大家: http://endless.logdown.com/posts/2014/05/05/find-out-the-winning-strategies-of-the-game-nim-and-grundy-number-notes 这个服务器可能是外国的?打开的很慢,不要认为自己的网炸了...哈哈哈 下面就贴一点自己为了做海报(Grun…
长为n的一列格子,轮流放同种棋子,率先使棋子连成3个者胜. 可以发现每次放一个棋子后,后手都不能放在[x-2,x+2]这个区间,那么相当于每次放棋将游戏分成了两个,不能放棋者败. 暴力求SG即可 /** @Date : 2017-10-14 22:50:13 * @FileName: POJ 3537 multi-sg 暴力SG.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https:…
POJ.1067 取石子游戏 (博弈论 威佐夫博弈) 题意分析 简单的威佐夫博弈 博弈论快速入门 代码总览 #include <cstdio> #include <cmath> #include <algorithm> using namespace std; int main() { int n,m; while(scanf("%d %d",&n,&m) != EOF){ if( n > m) swap(n,m); doubl…
Grundy值 当前状态的Grundy值就是除任意一步所能转移到的状态的Grundy值以外的最小非负整数, 以硬币问题一为例,可写成: int init_grundy() { sg[] = ; ;i <= x;i++) //递推求前x个SG值 { set<int>st; ;j < k;j++) if(a[j] <= i) st.insert(sg[i - a[j]]); ; while(st.count(g)) g++; sg[i] = g; } } Grundy值有什么用呢…