很简单的位模拟(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 ;
}

最新文章

  1. Oracle学习笔记七 锁
  2. [.net 面向对象程序设计进阶] (11) 序列化(Serialization)(三) 通过接口 IXmlSerializable 实现XML序列化 及 通用XML类
  3. 【转】详细分析Java中断机制
  4. Win10 UI介绍之Titlebar
  5. 浅析“依赖注入(DI)/控制反转(IOC)”的实现思路
  6. Volley的基本用法
  7. 通过HttpClient方式连接网络
  8. TopFreeTheme精选免费模板【20130701.特别版】
  9. The 10 Most Important Security Controls Missing in JavaEE--reference
  10. Base64算法
  11. Shell中变量的使用
  12. 由基于qml,c++的串口调试工具浅谈qml与c++混合编程
  13. JavaScript中的分号插入机制
  14. vue:简单方法替代vuex或者bus
  15. ABP官方文档翻译 4.4 授权
  16. stack的empty()
  17. Win10 自定义右键新建菜单
  18. pytest自动化7:assert断言
  19. (python)数据结构------列表
  20. 【个人阅读】M1/M2阶段总结

热门文章

  1. opengl笔记—— glMultMatrixf() 区别 glLoadMatrixf()
  2. 傅老师课堂:Java高级应用之Struts2+Spring2+Hibernate3大集成
  3. CCTF-PWN1&amp;&amp;PWN3
  4. UVA 12545 Bits Equalizer
  5. RadioButton、CheckBox与ToggleButton
  6. 2014.12.13 ASP.NET文件上传
  7. pythonj基础之 多线程
  8. mysql5 乱码问题解决方案
  9. 使用微信 SDK 上传图片到七牛
  10. 【JQ学习笔记】提示的效果