poj3710
来源:互联网 发布:套路 知乎 编辑:程序博客网 时间:2024/06/05 18:37
题目大意:
有N 个局部联通的图。
Harry 和Sally 轮流从图中删边,删去一条边后,不与根节点相连的部分将被移走。Sally 为先手。
图是通过从基础树中加一些边得到的。
所有形成的环保证不共用边,且只与基础树有一个公共点。
谁无路可走谁输。
有N 个局部联通的图。
Harry 和Sally 轮流从图中删边,删去一条边后,不与根节点相连的部分将被移走。Sally 为先手。
图是通过从基础树中加一些边得到的。
所有形成的环保证不共用边,且只与基础树有一个公共点。
谁无路可走谁输。
【输入】
多组数据
每组数据第一行m和k表示m个节点,k条边,1为根节点
接下来k行描述边
【输出】
对于每组数据输出谁必胜
2009年贾志豪的论文有讲
program poj3710;var a,b,tot,ans,n,m,k,i,j:longint; yes:array [0..101] of boolean; round,high,sg,father,root:array [0..101] of longint; point,next:array [0..1001] of longint;procedure connect (a,b:longint);begin inc(tot); point[tot]:=b; next[tot]:=root[a]; root[a]:=tot;end;procedure dfs (now,h:longint);var i:longint;begin yes[now]:=true; high[now]:=h; i:=root[now]; while i<>0 do begin if (point[i]<>father[now])and(point[i]<>now) then if not yes[point[i]] then begin father[point[i]]:=now; dfs(point[i],h+1); case round[now] of 0:sg[now]:=sg[now] xor (sg[point[i]]+1); 1:; 2:sg[now]:=sg[now] xor 1; end; round[now]:=0; end else if high[point[i]]<high[now] then if (high[now]-high[point[i]]) and 1 = 1 then round[point[i]]:=1 else round[point[i]]:=2; if point[i]=father[now] then father[now]:=0; i:=next[i]; end;end;begin while not seekeof do begin ans:=0; read(n); while n>0 do begin dec(n); read(m,k); fillchar(father,sizeof(father),0); fillchar(round,sizeof(round),0); fillchar(yes,sizeof(yes),false); fillchar(root,sizeof(root),0); fillchar(sg,sizeof(sg),0); tot:=0; for i:=1 to k do begin read(a,b); connect(a,b); connect(b,a); end; dfs(1,1); ans:=ans xor sg[1]; end; if ans=0 then writeln('Harry') else writeln('Sally'); end;end.
- poj3710
- POJ3710
- poj3710 Christmas Game 无向图 tarjan 连通分量
- [POJ3710]Christmas Game(博弈树的删边游戏)
- POJ3710 [图上博弈]无向图删边 经典的删边游戏
- 【POJ3710】Christmas Game 博弈 有限制的图上删边游戏(树形删边游戏进化1)
- NSOperation
- android布局设置Button或者ImageButton的背景透明 半透明 透明
- KMP Next求法 AC自动机 自动机 Trie POJ
- 任务计划
- 程序员新年要做的10个决定
- poj3710
- ubuntu root 初始密码问题
- Struts2基础知识
- 行列互换
- 基于XML配置的输入校验
- 荒林
- Linux 终端提示符设置
- 牛人的blog
- 文件操作函数