不吐槽。。

 #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. C语言程序判断文件夹是否存在

    #include <stdio.h> #include <io.h> int main(void){ if ( !access("C://Users/hui" ...

  2. A. Jeff and Digits(cf)

    A. Jeff and Digits time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. hihoCoder 1187

    今天BC爆0了....但是日子还是要过的....要回学校毕业了~~大学就这么“荒废”了. 这个是hihoCoder的1187,比较基础的一道题. 题目链接: http://hihocoder.com/ ...

  4. git add -A (用该命令添加文件时报错)

    前言 最近在学着不使用github客户端,而直接用git命令上传代码至github,当使用命令 git add -A 添加所有项目文件时报错    老实说我是蒙蔽的,因为从来没有遇到过这个错,确认输入 ...

  5. net .异步委托知识

    以前在编程中,异步用的比较少,导致C# 一些基础的 东西用法都不怎么熟悉,经常要用的时候在去查找资料比较被动,而已没真正里面理解起来,始终感觉不是自己的知识 (题外话) 首先委托关键字  Delega ...

  6. dotnet core 发布配置(测试数据库和正式数据库自动切换)

    一.起源 在进行项目开发时,常常要求开发环境,测试环境及正式环境的分离,并且不同环境运行的参数都是不一样的,比如监听地址,数据库连接信息等.当然我们把配置信息保存到一个文件中,每次发布的时候,可以先修 ...

  7. Shiro图解

  8. P1401 城市(30分,正解网络流)

    题目描述 N(2<=n<=200)个城市,M(1<=m<=40000)条无向边,你要找T(1<=T<=200)条从城市1到城市N的路,使得最长的边的长度最小,边不能 ...

  9. 如何在Eclipse中创建Web服务器

    使用Eclipse开发Web项目时,需要先配置Web服务器,如果已经配置好Web服务器,就不需要再重新配置了.也就是说,本节的内容不是开发每个项目时,都必须经过的步骤.创建Web服务器的具体步骤如下: ...

  10. java反射_01

    为什么要用反射? 举个栗子: package com.imooc.reflect; public class Work { // 定义一个word方法 public void word() { Sys ...