poj 2425 A Chess Game 博弈论】的更多相关文章

http://poj.org/problem?id=2425 典型的sg函数,建图搜sg函数预处理之后直接求每次游戏的异或和.仍然是因为看不懂题目卡了好久. 这道题大概有两个坑, 1.是搜索的时候vis数组应该在函数内声明(似乎这是我经常在搜索里犯的错误,为了省一点空间整道题都写错了): 2.是n个点的有向无环图边数上限是n^2(re了好久QAQ). 在漫长的查资料过程之后终于大概搞懂了sg函数的原理,愉快.下一篇大概会写一个小结. 代码 #include<cstdio> #include&l…
思路:SG函数应用!! 代码如下: #include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<cstring> using namespace std; ],n; vector<]; int dfs(int now) { ) return sg[now]; ]={}; ;i<p[now].size();i++) vis[dfs(p[now…
http://poj.org/problem?id=2425 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct node { int to,next; }e[]; ],Ecou; ]; void add_edge(int u,int v) { e[Ecou].to=v; e[Ecou].next=head[…
A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3551   Accepted: 1440 Description Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The…
题目链接题意:给定一个有向无环图(DAG),上面放有一些旗子,旗子可以重合,两个人轮流操作,每次可以把一个旗子从一个位置移动到相邻的位置,无法移动时输,询问先手是否必胜. 这道题可以把每个旗子看作单独的一个游戏,那么所有这些旗子的状态SG值,就是这些旗子各自SG值的Xor和,可以记忆化搜索dfs,暴力算SG值判断即可. #include<iostream> #include<cstdio> #include<algorithm> #include<cstring&…
题意:给你一个有向无环图,再给你图上的棋子,每人每次只能移动一个棋子,当轮到你不能移动棋子是就输了,棋子可以同时在一个点 比赛时就差这题没ak,做了几天博弈终于搞懂了. #include <iostream> #include <cstdio> #include<vector> #include<cstring> using namespace std; #define N 1010 vector<int> adj[N]; int sg[N],n…
题意:给一个有向图,然后个m颗石头放在图上的几个点上,每次只能移动一步,如果不能移动者败 思路:dfs打表sg函数,然后求异或和 代码: #include<queue> #include<cstring> #include<set> #include<map> #include<stack> #include<cmath> #include<vector> #include<cstdio> #include&l…
A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3791   Accepted: 1549 Description Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The…
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…
Let's design a new chess game. There are N positions to hold M chesses in this game. Multiple chesses can be located in the same position. The positions are constituted as a topological graph, i.e. there are directed edges connecting some positions,…