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. ...
随机推荐
- C++ this指针 全部
在每一个成员函数中都包含一个特殊的指针,这个指针的名字是固定的.叫做this.它是指向本类对象的指针,它的值是当前被调用的成员函数所在的对象的起 始地址.例如:当调用成员函数a.volume ...
- Truck History(prim)
http://poj.org/problem?id=1789 读不懂题再简单也不会做,英语是硬伤到哪都是真理,sad++. 此题就是一个最小生成树,两点之间的权值是毎两串之间的不同字母数. #incl ...
- 洛谷P1077 摆花(背包dp)
P1077 摆花 题目描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号.为了在门口展出更多种花,规定第i种花不能 ...
- POJ 1985 求树的直径 两边搜OR DP
Cow Marathon Description After hearing about the epidemic of obesity in the USA, Farmer John wants h ...
- Jenkins自动化部署.net程序
一.安装Jenkins 百度上一大堆就不做说明了. 二.构建.net前的准备 1.安装MSBUILD.EXE插件 1.1.进去jenkins->系统管理->插件管理 1.2.配置MSBUI ...
- Java基础13一异常
1.异常概念 异常是程序在运行期发生的不正常的事件,它会打断指令的正常执行流程. 设计良好的程序应该在异常发生时提供处理这些不正常事件的方法,使程序不会因为异常的发生而阻断或产生不可预见的结果. Ja ...
- APP开发中的弹窗体系,UI设计师不能忽视的地方
1. 弹窗的定义 弹窗分为模态弹窗和非模态弹窗两种. 弹窗分类 模态弹窗:很容易打断用户的操作行为,用户必须回应,否则不能进行其他操作. 非模态弹窗:不会影响用户的操作,用户可以不对其进行回应,非模态 ...
- 【转载】linux环境下大数据网站搬家
这里说的大数据是指你的网站数据库大小至少超过了500M,当然只有50M的网站也同样可以用这样的方法来轻松安全的实现网站搬家,前提是你使用的是linux环境下的VPS或者独立服务器. 我们假设你的网站域 ...
- 图像局部显著性—点特征(GLOH)
基于古老的Marr视觉理论,视觉识别和场景重建的基础即第一阶段为局部显著性探测.探测到的主要特征为直觉上可刺激底层视觉的局部显著性--特征点.特征线.特征块. 相关介绍:局部特征显著性-点特征(SIF ...
- Content-Encoding与Content-Type的区别
RFC 2616 for HTTP 1.1 specifies how web servers must indicate encoding transformations using the Con ...