很简单的位模拟(bit-mask),可惜队友读题误以为很难,没有及时跟我交流,不然应该很早就可以出了。

  很容易看出来,总共才16个点、24条边。用一个int类型数字就可以描述这个图了,按照16点的关系可以找出已确定的那些边。然后就是很简单的DP了。

  

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int jb[]={ (<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<),
(<<)|(<<)|(<<)|(<<)
};
int d[][];
void gao(){
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
d[][]=,d[][]=,d[][]=;
}
int zhuge(int x,int y){
if(x>y) swap(x,y);
return d[x][y];
}
int score[],lastc;
int get_lc(int em){
int lc=;
for(int i=;i<;i++)
if((em&jb[i])==jb[i])
lc++;
return lc;
}
int DP(int sc[],int em,int id,int run,int lastc){
if(run > ) {
if(sc[id]>sc[-id]) return ;
return ;
}
for(int i=;i<=;i++)
if(!((<<i)&em)){
int n_sc[]={sc[],sc[]};
int n_em=em|(<<i),lc=get_lc(n_em);
n_sc[id] += lc-lastc;
if(!DP(n_sc,n_em,-id,run+,lc)) return ;
}
return ;
}
int main()
{
gao();
int cases; cin>>cases;
for(int cas=;cas<=cases;cas++){
score[]=score[]=;
lastc=;
int id=,em=;
int pl,run=; cin>>pl;
while(run<=pl){
int x,y,e,lc;
scanf("%d%d",&x,&y); e=zhuge(x,y);
em |= <<e; lc = get_lc(em);
score[id] += lc-lastc; lastc=lc;
id=-id;
run++;
}
int status=DP(score,em,id,run,lastc);
printf("Case #%d: ",cas);
if((id==&&status) || (id==&&!status)) printf("Tom200\n");
else printf("Jerry404\n");
}
return ;
}

hdu4753的更多相关文章

  1. hdu4753 Fishhead’s Little Game 状态压缩,总和一定的博弈

    此题和UVA 10891 Game of Sum 总和一定的博弈,区间dp是一个道理,就是预处理麻烦 这是南京网络赛的一题,一直没做,今天做了,虽然时间有点长,但是1ac,这几乎是南京现场赛的最后一道 ...

  2. HDU4753 Fishhead’s Little Game——2013 ACM/ICPC Asia Regional Nanjing Online

    今天比赛又是做得好水的.被狂虐啊. 比赛两个多小时一直没出题,遒遒最先交的若干发都wa了.T_T 我独自在一遍苦思了1006这个题,还好最后把这个题目A掉了,不然又是深坑队友. 题目的意思我就不多说了 ...

随机推荐

  1. Win32K里的死循环

    引用注明>> [作者:张佩][原文:www.YiiYee.cn/blog] 这是我到新公司后上手的第一个issue.一线project师找到我,说有一个urgent issue有没有兴趣看 ...

  2. 实现简答LinkedList

    package com.表栈和队列; import java.util.Iterator; /**  * 实现LinkedList  * 60页  * @author zj  *  * @param ...

  3. Do we need other languages other than C and C++?

    There were hundreds of or thousands of programming languages created since the invention of computer ...

  4. Android开发之自定义圆角矩形图片ImageView的实现 - Jamy Cai

    android中的ImageView只能显示矩形的图片,这样一来不能满足我们其他的需求,比如要显示圆角矩形的图片,这个时候,我们就需要自定义ImageView了,其原理就是首先获取到图片的Bitmap ...

  5. Net Configuration Assistant和Net Manager的区别

    1.Net Configuration Assistant和Net Manager在oracle的配置工具中,Net Configuration Assistant(网络配置助手)和Net Manag ...

  6. appium自动化测试

    appium官网:http://appium.io/index.html?lang=zh Requirements Your environment needs to be setup for the ...

  7. CentOS 6 安装 python and pip

    yum update yum list python*     //查看可安装python包 yum install python34.i686_64 wget https://bootstrap.p ...

  8. Java多线程相关知识

    1)wait()  notify()  sleep() sleep是Thread类的函数,wait和notify是Object的函数. sleep的时候keep对象锁,wait的时候release 对 ...

  9. zoj1107 FatMouse and Cheese

    这是一道记忆化搜索,也就是有记录的搜索. 注意点:一次走k步不能拐弯 int bfs(int x,int y) { ; ) return ans[x][y]; ;i<;i++) { ;j< ...

  10. 文件搜索查找功能VC++

    1.搜索指定文件夹下的文件名和路径 #undef UNICODE #include <iostream> #include <string> #include <vect ...