博客
关于我
agc017D Game on Tree
阅读量:277 次
发布时间:2019-03-01

本文共 872 字,大约阅读时间需要 2 分钟。

题目链接

题意简述

现在有一棵树,Alice和Bob要玩一个游戏。Alice先手,他们轮流断开树上的一条边,并将不与 1 1 1连接的连通块删去。如果轮到一个人操作时只剩一个点则判他负。问是否存在先手必胜策略。

题解

S G ( i ) = x o r ( S G ( s o n ) + 1 ) SG(i)=xor(SG(son)+1) SG(i)=xor(SG(son)+1)

代码

#include 
int read(){ int x=0,f=1; char ch=getchar(); while((ch<'0')||(ch>'9')) { if(ch=='-') { f=-f; } ch=getchar(); } while((ch>='0')&&(ch<='9')) { x=x*10+ch-'0'; ch=getchar(); } return x*f;}const int maxn=100000;int n,pre[maxn*2+10],now[maxn+10],son[maxn*2+10],tot,f[maxn+10];int ins(int a,int b){ pre[++tot]=now[a]; now[a]=tot; son[tot]=b; return 0;}int search(int u,int fa){ for(int i=now[u]; i; i=pre[i]) { int v=son[i]; if(v==fa) { continue; } search(v,u); f[u]^=(f[v]+1); } return 0;}int main(){ n=read(); for(int i=1; i

转载地址:http://icwo.baihongyu.com/

你可能感兴趣的文章
mysql 常用
查看>>
MySQL 常用列类型
查看>>
mysql 常用命令
查看>>
Mysql 常见ALTER TABLE操作
查看>>
MySQL 常见的 9 种优化方法
查看>>
MySQL 常见的开放性问题
查看>>
Mysql 常见错误
查看>>
mysql 常见问题
查看>>
MYSQL 幻读(Phantom Problem)不可重复读
查看>>
mysql 往字段后面加字符串
查看>>
mysql 快照读 幻读_innodb当前读 与 快照读 and rr级别是否真正避免了幻读
查看>>
MySQL 快速创建千万级测试数据
查看>>
mysql 快速自增假数据, 新增假数据,mysql自增假数据
查看>>
MySql 手动执行主从备份
查看>>
Mysql 批量修改四种方式效率对比(一)
查看>>
mysql 批量插入
查看>>
Mysql 报错 Field 'id' doesn't have a default value
查看>>
MySQL 报错:Duplicate entry 'xxx' for key 'UNIQ_XXXX'
查看>>
Mysql 拼接多个字段作为查询条件查询方法
查看>>
mysql 排序id_mysql如何按特定id排序
查看>>