UVA 10187 From Dusk Till Dawn /PC 110907
不吐槽。。
#include <iostream>
#include <map>
#include <queue> //无语的水题。节哀吧。且这道题不严谨,因为没说是无环。算了,不吐槽了。优先队列+BFS using namespace std;
const int inf=;
const int MAxN=;
const int MAXM=;
typedef struct ei{
int v;
int begin;
int ends;
}edge;
vector<edge>Edge[MAxN];
typedef struct ci{
int city;
int litre;
int artime;
bool operator<(const ci &A)const {
return (litre>A.litre) ;
}
}City;
City tmp,pushed;
int m,tot;
int start_city,end_city;
int LITRES; void init(){
for(int i=;i<MAxN;i++)
Edge[i].clear();
} void addedge(int u,int v,int be,int en){
Edge[u].push_back((edge){v,be,en});
} bool slove(){
int now; int tmptime,pushtime;
priority_queue<City>que;
tmp.city=start_city; tmp.artime=; tmp.litre=;
que.push(tmp);
while(!que.empty()){
tmp=que.top();
que.pop();
now=tmp.city;
if(now==end_city){
LITRES=tmp.litre;
return true;
}
for(int e=;e<Edge[now].size();e++){
tmptime=tmp.artime; pushtime=Edge[now][e].begin;
int used=tmp.litre;
if(pushtime<tmptime){
used++;
}
que.push((City){Edge[now][e].v,used,Edge[now][e].ends});
}
}
return false;
} int main(){
int T; int from,to; int Cas=;
string start,ends; int stt,edt,waste;
cin>>T;
while(T--){
Cas++;
init();
map<string,int>citys;
cin>>m;
for (int i = ; i <= m; i++)
{
cin >> start >> ends >> stt >> waste;
if (citys.find(start) == citys.end())
{
from = citys.size();
citys[start] = from;
}
else
from = citys[start]; if (citys.find(ends) == citys.end())
{
to = citys.size();
citys[ends] = to;
}
else
to = citys[ends];
if(((stt>=)||(stt<=&&stt>=))){ //我调了一天,把自己原来写的改得面目全非,对着别人的改啊改
//都几乎改成别人的了,终于,一道水题,让我过了。当我把(stt>=18&&stt<=24)改成(stt>=18)之后,过了。哈哈哈
//坑爹的测试数据啊。肯定是有测试数据超过了24。尼玛,还我一早上的时间,kao,一万个操。。 还以为是我的算法错了呢
//原来是测试数据坑..
if(stt<=)
stt+=;
edt=stt+waste;
if(edt<=){
Edge[from].push_back((edge){to,stt,edt});
}
} }
cin>>start>>ends;
if(start==ends){
cout << "Test Case " << Cas << "." << endl;
cout << "Vladimir needs 0 litre(s) of blood." << endl;
continue;
}
if(citys.find(start)==citys.end()
||citys.find(ends)==citys.end()){
cout << "Test Case " << Cas << "." << endl;
cout << "There is no route Vladimir can take." << endl;
continue;
}
start_city=citys[start]; end_city=citys[ends];
if(slove()){
cout << "Test Case " << Cas << "." << endl;
cout << "Vladimir needs " << LITRES << " litre(s) of blood." << endl;
}
else {
cout << "Test Case " << Cas << "." << endl;
cout << "There is no route Vladimir can take." << endl;
}
}
return ;
}
UVA 10187 From Dusk Till Dawn /PC 110907的更多相关文章
- POJ 2267 From Dusk till Dawn or: Vladimir the Vampire(最短路变形)
题意: 有一个吸血鬼要旅游, 他只能在晚上6点到第二天凌晨6点行动(18:00 ~ 6:00), 然后每天中午12点要喝1L的血(12:00), 现有m条火车的发车时间和行程时间, 问他从a到达b需要 ...
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- ACM训练计划step 1 [非原创]
(Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- How To Download Youtube Videos Without any software
https://www.quora.com/What-is-the-best-way-to-download-YouTube-videos-for-free There are various met ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- 2016CVPR论文集
http://www.cv-foundation.org/openaccess/CVPR2016.py ORAL SESSION Image Captioning and Question Answe ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
随机推荐
- 麦森数--NOIP2003
题目描述 形如2P−12^{P}-12P−1 的素数称为麦森数,这时PPP 一定也是个素数.但反过来不一定,即如果PPP 是个素数,2P−12^{P}-12P−1 不一定也是素数.到1998年底,人们 ...
- CSS--浏览器CSS Hack 收集
所谓的Hack就是只有特定浏览器才能识别这段hack代码.Hack 不是什么好东西,除非没有办法,我们尽量还是不要用着玩意. 下面是各个浏览器的CSS Hack 列表. Firefox 浏览器 @-m ...
- (Go)04.go工作区目录规范及简单例子
一.规范目录结构 D:\project\src\go_dev\day1\example1 二.设置GOPAH环境变量 三.hello world 1.hello world package main ...
- 排序系列 之 归并排序算法 —— Java实现
基本思想: 归并排序法是分治法的典型实例,分为分割和归并两部分. 把一个数组分为大小相近的子数组(分割),分别把子数组排好序后,通过合成一个大的排好序的数组(归并). 实例: 先分割成每个子序列只有一 ...
- mysql出错代码
1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件导致删除数据库失败 1010:不能删除数据目 ...
- 【LuoguP2210 USACO】 Haywire
这种答案跟序列排列顺序有关的,n比较小的(稍微大一点的也可以),求最优解的,一般都可以随机化过 随机化不一定是模拟退火或是什么遗传蚁群 哪怕只是直接随机化一个序列,只要你随机的次数够多,它都能找到正解 ...
- 【DP】编辑距离
日常吐槽:关于DP,有一种莫名的恐惧...maybe源于与mtw大佬与quantum11大佬,初中时抬老师爬楼梯的经历... 言归正传: 编辑距离 [题目描述] 设A和B是两个字符串.我们要用最少的字 ...
- SQL连接其它服务器操作
Exec sp_droplinkedsrvlogin ZYB,Null --删除映射(录与链接服务器上远程登录之间的映射) Exec sp_dropserver ZYB --删除远程服务器链接 EXE ...
- WPF TextBox 仅允许输入数字
因为在 IValueConverter 实现中,当文本不能转换为目标类型时返回 DependencyProperty.UnsetValue ,Validation.GetHasError 返回 tru ...
- 关于AS使用git的那些奇葩事儿
首先致谢: http://blog.csdn.net/a10615/article/details/52135617, 我们不生产代码, 我们只做大自然的搬运工! 总结 1. 首次无法push问题: ...