博弈论

  贾志豪论文上的题目……题解请看论文

  Orz了一下Hzwer

 Source Code
Problem: User: sdfzyhy
Memory: 716K Time: 0MS
Language: G++ Result: Accepted Source Code //POJ 3710
#include<cstdio>
#include<cstring>
#include<iostream>
#define F(i,j,n) for(int i=j;i<=n;++i)
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
const int N=,INF=~0u>>;
const double eps=1e-;
/*******************template********************/
int to[N],next[N],head[N],cnt,s[N],top;
bool vis[N],ve[N],w[N];
void add(int x,int y){
to[++cnt]=y; next[cnt]=head[x]; head[x]=cnt;
to[++cnt]=x; next[cnt]=head[y]; head[y]=cnt;
}
int dfs(int x){
vis[x]=;
int ans=;
s[++top]=x;
for(int i=head[x];i;i=next[i])
if(!ve[i]){
ve[i]=ve[i^]=;
int temp;
if (!vis[to[i]]) temp=dfs(to[i])+;
else{
int q=s[top--];
while(q!=to[i]){
w[q]=;//环上节点标记
q=s[top--];
}
++top;
return ;
}//缩环
if(w[to[i]]) ans^=temp%;
else ans^=temp;
}
return ans;
}
void clear(){
memset(head,,sizeof head);
memset(next,,sizeof next);
memset(vis,,sizeof vis);
memset(ve,,sizeof ve);
memset(w,,sizeof w);
top=; cnt=;
}
int main(){
int T,n,m,x,y;
while(scanf("%d",&T)!=EOF){
int ans=;
F(i,,T){
clear();
n=getint(); m=getint();
F(i,,m){
x=getint(); y=getint();
add(x,y);
}
ans^=dfs();
}
puts(ans ? "Sally" : "Harry");
}
return ;
}

【POJ】【3710】Christmas Game的更多相关文章

  1. 【 POJ - 1204 Word Puzzles】(Trie+爆搜|AC自动机)

    Word Puzzles Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 10782 Accepted: 4076 Special ...

  2. 【POJ 1459 power network】

    不可以理解的是,测评站上的0ms是怎么搞出来的. 这一题在建立超级源点和超级汇点后就变得温和可爱了.其实它本身就温和可爱.对比了能够找到的题解: (1)艾德蒙·卡普算法(2)迪尼克算法(3)改进版艾德 ...

  3. 【POJ 2728 Desert King】

    Time Limit: 3000MSMemory Limit: 65536K Total Submissions: 27109Accepted: 7527 Description David the ...

  4. 【POJ 2976 Dropping tests】

    Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 13849Accepted: 4851 Description In a certa ...

  5. 【POJ 3080 Blue Jeans】

    Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 19026Accepted: 8466 Description The Genogr ...

  6. 【POJ各种模板汇总】(写在逆风省选前)(不断更新中)

    1.POJ1258 水水的prim……不过poj上硬是没过,wikioi上的原题却过了 #include<cstring> #include<algorithm> #inclu ...

  7. 【POJ 3669 Meteor Shower】简单BFS

    流星雨撞击地球(平面直角坐标第一象限),问到达安全地带的最少时间. 对于每颗流星雨i,在ti时刻撞击(xi,yi)点,同时导致(xi,yi)和上下左右相邻的点在ti以后的时刻(包括t)不能再经过(被封 ...

  8. 【POJ 2823 Sliding Window】 单调队列

    题目大意:给n个数,一个长度为k(k<n)的闭区间从0滑动到n,求滑动中区间的最大值序列和最小值序列. 最大值和最小值是类似的,在此以最大值为例分析. 数据结构要求:能保存最多k个元素,快速取得 ...

  9. 【POJ 2406 Power Strings】

    Time Limit: 3000MSMemory Limit: 65536K Description Given two strings a and b we define a*b to be the ...

  10. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

随机推荐

  1. php返回json数据函数例子

    json_encode()函数用法. echo json_encode(array('a'=>'bbbb','c'=>'ddddd'); 这样就会生成一个标准的json格式的数据 代码如下 ...

  2. Java中List与Map初始化的一些写法

    Java的在还没有发现新写法之前时,我一直是这么初始化List跟Map: 代码如下 复制代码  //初始化List    List<string> list = new ArrayList ...

  3. JS获取非行间样式及兼容问题

    获取非行间样式: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  4. javascript 获取项目根路径

    /** * http://localhost:8088/projectName */ function getRootPath(){ //获取当前网址,如: http://localhost:8088 ...

  5. PHP 如何判断当前用户已在别处登录

    出处:http://bbs.lampbrother.net/read-htm-tid-121909-ds-1.html#tpc 主要思路:1.登录时,将用户的SessionID记录下来2.验证登录时, ...

  6. ASP.NET MVC 应用程序的安全性,看一眼你就会了

    1.使用Authorize特性登陆对于我们开发程序而言,基本上都是要求角色成员使用Authorize特性,比如,对于管理员而言角色是Admin,对于登陆注册登陆用户而言是User那么我们在用户登陆的时 ...

  7. 转:JAVA中this用法小结

    转:http://blog.sina.com.cn/s/blog_6a6badc90100t8hm.html#SinaEditor_Temp_FontName Java关键字this只能用于方法方法体 ...

  8. SQL中的类型转换

    SQL中的类型转换一直是以块心病,因为用得比较少,所以每次想用的时候都要想半天,恰好这段时间比较空,整理整理.今天写个标题先.

  9. SQL2012 附加数据库提示5120错误解决方法

    在win8.1 x64系统上使用sql2012进行附加数据库(包括在x86系统正在使用的数据库文件,直接拷贝附加在X64系统中)时,提示无法打开文件,5120错误. 这个错误是因为没有操作权限,所以附 ...

  10. c# this.location和e.X的区别

    this.location是窗口当前位置 e.X是具体事件的相对坐标 size是窗口尺寸宽和高