hdu4753
2024-10-10 23:37:57
很简单的位模拟(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 ;
}
最新文章
- Oracle学习笔记七 锁
- [.net 面向对象程序设计进阶] (11) 序列化(Serialization)(三) 通过接口 IXmlSerializable 实现XML序列化 及 通用XML类
- 【转】详细分析Java中断机制
- Win10 UI介绍之Titlebar
- 浅析“依赖注入(DI)/控制反转(IOC)”的实现思路
- Volley的基本用法
- 通过HttpClient方式连接网络
- TopFreeTheme精选免费模板【20130701.特别版】
- The 10 Most Important Security Controls Missing in JavaEE--reference
- Base64算法
- Shell中变量的使用
- 由基于qml,c++的串口调试工具浅谈qml与c++混合编程
- JavaScript中的分号插入机制
- vue:简单方法替代vuex或者bus
- ABP官方文档翻译 4.4 授权
- stack的empty()
- Win10 自定义右键新建菜单
- pytest自动化7:assert断言
- (python)数据结构------列表
- 【个人阅读】M1/M2阶段总结
热门文章
- opengl笔记—— glMultMatrixf() 区别 glLoadMatrixf()
- 傅老师课堂:Java高级应用之Struts2+Spring2+Hibernate3大集成
- CCTF-PWN1&;&;PWN3
- UVA 12545 Bits Equalizer
- RadioButton、CheckBox与ToggleButton
- 2014.12.13 ASP.NET文件上传
- pythonj基础之 多线程
- mysql5 乱码问题解决方案
- 使用微信 SDK 上传图片到七牛
- 【JQ学习笔记】提示的效果