UVA 658 - It's not a Bug, it's a Feature!
来源:互联网 发布:java程序员转行做什么 编辑:程序博客网 时间:2024/05/20 07:53
这道题题意是:某个软件有n个漏洞m的补丁,而每个补丁修复漏洞有前提条件,即有些漏洞必须存在或不存在,每个补丁的修复时间各不相同,现在有n个漏洞,让你求出把这n个漏洞全部修复所花的最少时间。
这道题实际是个最短路问题,可用隐式图搜索来做。这道题比较有技巧性的地方是判断补丁能否修复当前漏洞,如果直接用字符串,会超时,这里我借鉴了别人的经验,用两个整数的位来表示,第一个数把+的位置成1,第二个数把-的位置成1。
例如:++--0-+- --++--00,我用f[2]表示前边的串,b[2]表示后边的串。f[0] = "11000010",f[1] = "00110101", b[0] = "00110000",b[1] = "11001100",当前我有一个串"++--+-+-"t,t表示为"11001010",1意思是有漏洞,0表示没有,它先与f[0]做与运算,看结果是否为f[0],即判断在当前串是否有所必须的漏洞,然后t取反,再与f[1]做与运算,判断结果是否为f[1],即判断串是否没有所不要的漏洞,如果都为真,便可用此补丁,t |= b[0],把新的漏洞加上,t &= (~b[1]), 把漏洞去掉。开始状态全部为1,结束状态全部为0。
程序代码:
- It's not a Bug, it's a Feature! UVA
- It's not a Bug, it's a Feature! UVA
- It's not a Bug, it's a Feature! UVA
- It's not a Bug, it's a Feature! UVA
- 658 - It's not a Bug, it's a Feature!
- uva 658 UVA 658 It's not a Bug, it's a Feature!
- UVA 658 - It's not a Bug, it's a Feature!
- Uva 658 - It's not a Bug, it's a Feature!//最短路
- UVA - 658 It's not a Bug, it's a Feature!
- uva 658 - It's not a Bug, it's a Feature!(优先队列Dijkstra)
- UVA 658 - It's not a Bug, it's a Feature!(最短路)
- UVa 658 It's not a Bug, it's a Feature! / SPFA
- (beginer) 最短路 UVA 658 It\'s not a Bug, it\'s a Feature!
- 【UVA】658 - It's not a Bug, it's a Feature!(隐式图 + 位运算)
- UVA 658 It's not a Bug, it's a Feature!
- UVa 658 - It's not a Bug, it's a Feature!(Dijkstra算法)
- UVA - 658 It's not a Bug, it's a Feature! SPFA
- UVA - 658 It’s not a Bug, it’s a Feature!(优先队列Dijkstra)
- java 运行时,提示索引中丢失in或out参数异常
- ASP.NET:在线打印Excel文档
- WinPcap还原HTTP
- 数组非数字键名引号的必要性
- 《Google Android 开发入门和实践》摘要
- UVA 658 - It's not a Bug, it's a Feature!
- ubuntu签名无法验证 NO_PUBKEY 033431536A423791的解决方法
- 1144 Network
- Java 多线程之 interrupt(1)
- EverNote 极致的免费笔记资料管理软件 (数据网络同步、支持PC、Mac与手机多平台) 转自:http://www.iplaysoft.com/evernote.html
- PDF电子书--页码不对应解决方法。
- zz: RTSP简介以及常用方法使用实例
- PHP受locale影响的函数
- python写的代码生成工具