博弈论

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

  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. TableViewCell自适应高度

    //初始化TableView时设置 self.tv.estimatedRowHeight=54;self.tv.rowHeight=UITableViewAutomaticDimension;

  2. DailyWallpaper - V1.01 released

    桌面每日一图 最近发现美国国家地理网站上有个photo of the day很不错,地址在这里.http://photography.nationalgeographic.com/photograph ...

  3. ant条件逻辑

    <condition property="sdk-folder" value="E:\android\android-sdk\adt-bundle-windows- ...

  4. 3.servlet实现页面的跳转

    效果: 在网页的输入框中输入lily,跳到成功的页面(请求转发),输入的不是lily则跳到百度的页面(跳到工程之外的页面,则是请求重定向) 1.建Web project“2Servlet_Basic” ...

  5. Spring MVC的启动过程

    一.概述 下面一个基本的运用springMVC的的web.xml的配置,这里要注意两个地方,一个是ContextLoadListener,一个是DispatcherServlet.web容器正是通过这 ...

  6. Tomcat启动超时

    当启动tomcat时候出现 Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the s ...

  7. TCP之Socket的编程

    Socket是网络编程的一个抽象的概念,通常我们用Socket来表示服务器与客户端间的网络连接, 即用Socket表示"打开了一个网络连接", 而打开一个网络连接需要知道目标电脑的 ...

  8. angular这个大梗的学习笔记

    angular定义一个模块(module)及控制器(controller)的局部声明方法: var app=angular.module("Myapp",[]); myapp.co ...

  9. js学习笔记一类型、值和变量

    js的数据类型分为两类:原始类型和对象类型 原始类型包括数字.字符串和布尔值 js中有2个特殊的原始值:null(空)和undefined(未定义) 对象是属性的集合,每个属性都由名/值对组成 js的 ...

  10. Docker 启动失败Starting docker (via systemctl): Job for docker.service failed

    Starting docker (via systemctl):  Job for docker.service failed. See 'systemctl status docker.servic ...