不吐槽。。

 #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的更多相关文章

  1. POJ 2267 From Dusk till Dawn or: Vladimir the Vampire(最短路变形)

    题意: 有一个吸血鬼要旅游, 他只能在晚上6点到第二天凌晨6点行动(18:00 ~ 6:00), 然后每天中午12点要喝1L的血(12:00), 现有m条火车的发车时间和行程时间, 问他从a到达b需要 ...

  2. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  3. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

  4. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  5. 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 ...

  6. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  7. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  8. 2016CVPR论文集

    http://www.cv-foundation.org/openaccess/CVPR2016.py ORAL SESSION Image Captioning and Question Answe ...

  9. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

随机推荐

  1. Swift备忘录

    Swift 备忘录 2015-4 一.简介 1.Swift 语言由苹果公司在2010年7月开始设计,在 2014 年6月推出,在 2015 年 12 月 3 日开源 2.特点(官方): (1)苹果宣称 ...

  2. css定位、position与float同时使用的情况

    一.css定位 CSS 有三种基本的定位机制:普通流.浮动和绝对定位. 1.普通流:未专门指定的元素都在普通流中定位,position:static/relative;和float:none;也在普通 ...

  3. 0605-类的继承、重写、parent、final

    定义一个子类(man) //定义一个类 class renlei{ var $name = '王五'; var $age = ''; var $sex = ''; var $todo = ''; fu ...

  4. Python 36 死锁现象和递归锁、信号量、Event事件、线程queue

    一:死锁现象和递归锁 所谓死锁: 是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永远 ...

  5. Spring Cloud (3) 服务消费者-Ribbon

    在上一篇中使用LoadBalancerClient接口实现了获取某个服务的具体实例,并根据实例信息发起服务接口消费请求.但是这样的做法需要我们手工的区编写服务选取.连接拼接等繁琐的工作,对于开发人员来 ...

  6. Laravel5.1 学习笔记2, 路由

    安装的说明请看文档, laravel 安装 #基本路由 你将在 app/Http/routes.php 文件定义大部分路由, 这些路由将被App\Providers\RouteServiceProvi ...

  7. Redis配置文件各项参数说明及性能调优

    Redis配置文件参数说明: 1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize no 2. 当Redis以守护进程方式运行时,Redis默 ...

  8. (List)写一个函数reverseList,该函数能够接受一个List,然后把该List 倒序排列。 例如:  List list = new ArrayList();  list.add(“Hello”);  list.add(“World”);  list.add(“Learn”); //此时list 为Hello World Learn  rever

    import java.util.ArrayList; import java.util.List; public class AA { public static void main(String[ ...

  9. ★Java面向对象(一)——————————基本概念

    package boll; /* 用Java语言对现实生活中的事物进行描述. 通过类的形式来体现, 怎么描述呢? 对于事物的描述通常只有两个方面,一个是属性,一个是行为. 只要明确该事物的行为和属性并 ...

  10. OpenCV: 图像连通域检测的递归算法

    序言:清除链接边缘,可以使用数组进行递归运算; 连通域检测的递归算法是定义级别的检测算法,且是无优化和无语义失误的. 同样可用于寻找连通域 void ClearEdge(CvMat* MM,CvPoi ...