不吐槽。。

 #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. AAC帧格式及编码介绍

    参考资料: AAC以adts格式封装的分析:http://wenku.baidu.com/view/45c755fd910ef12d2af9e74c.html aac编码介绍:http://wenku ...

  2. [Apple开发者帐户帮助]三、创建证书(1)证书概述

    在开发应用程序的过程中,您将创建不同的证书类型,以便在不同的上下文中使用.您将为iOS,tvOS和watchOS应用程序使用相同的证书集,并为macOS应用程序使用不同的证书集.您将使用开发证书在设备 ...

  3. html body中的标签

    HTML中的标签有两类 一.字体标签 字体标签包含:h1~h6.<font>.<u>.<b>.<strong><em>.<sup> ...

  4. Combotree--别样的构建层级json字符串

    1.先看效果 2.需要使用层级json格式,如: 3.先不要着急怎么去实现它,先来想想怎么用对象来描述它 4.代码 protected void Page_Load(object sender, Ev ...

  5. 浏览器缓存机制(HTTP缓存机制)

    其机制是根据HTTP报文的缓存标识进行的. 过程:浏览器发起HTTP请求 – 服务器响应该请求.那么浏览器第一次向服务器发起该请求后拿到请求结果,会根据响应报文中HTTP头的缓存标识,决定是否缓存结果 ...

  6. SSIS SQL Server配置自动作业

    目录: 一. 用SSMS配置作业,自助调度: 二.用SSMS调SSIS包: 一. 用SSMS配置作业,自助调度: 为验证数据,先创建一个表: CREATE TABLE test_table (id I ...

  7. mongoose 操作 mongodb 笔记 (自己的笔记,自己看的)

    mongodb下载/安装 mongoose   npm install --save mongoose mongoose 数据库连接 const mongoose = require('mongoos ...

  8. 《Linux程序设计》笔记(二)shell程序设计

    1. 进程树形显示 ps -e f 2. 重定向 > 覆盖文件 >> 附加至文件 1> 标准输出 2> 标准错误输出 0 代表一个程序的标准输入 3. 程序可以在当前目录 ...

  9. C# MVC 获得程序运行路径

    string filePath = System.Web.HttpContext.Current.Request.MapPath("~/Upload"); //由虚拟路径指定的服务 ...

  10. Combobox 下拉框赋值

    string sql = "select distinct RoleName from tb_Role"; DataTable dt = SqlHelper.DataTable(s ...