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. ...
随机推荐
- 复习--二叉树&&树
树是一种很常用的数据结构,日后的学习中会经常碰到运用树的知识. //构造二叉树#include<cstdio> #include<iostream> #include<a ...
- django自带权限控制系统的使用和分析
1.django的权限控制相关表及其相互间的关系: django的所有权限信息存放在auth_permission表中,用户user和用户组group都可以有对应的权限permission.分别存放在 ...
- git拉取远端改变,但是不覆盖本地的修改
1.git stash 2.git fetch weixin-old-remote 3.git rebase weixin-old-remote/main151028_wxpay_main15100 ...
- aspectC++常用命令
常用命令:1.ag++ main.cc //在工程目录下产生编译后的exe2.ag++ main.cc --weave_only //产生.acc 纯c++文件3.ag++ main.cc --gen ...
- Spring Boot 打 war 包的步骤
## Spring Boot 打 war 包的步骤 1. 添加 spring-boot-start-tomcat 的 provided 依赖 ``` <dependency> <gr ...
- ThinkPHP3.2.3扩展之自动分词获取关键字
ThinkPHP自动获取关键词调用在线discuz词库 先按照下图路径放好插件 /** * 自动获取关键词(调用第三方插件) * @return [type] [description] * www. ...
- CAS配置(1)SSL证书配置
一.配置源码 源码配置稍后提供 二.系统环境安装 安装JDK配置,版本>=1.7 环境变量配置(参考): JAVA_HOME=C:\Program Files x86)\Java\jdk1.7. ...
- python 字符编码的两种方式写法:# coding=utf-8和# -*- coding:utf-8 -*-
python运行文件是总会出现乱码问题,为了解决这个问题,在文件开头加上: # coding=utf-8 或者 # -*- coding:utf-8 -*- # coding=<encodin ...
- Spring的AOP机制---- AOP环绕通知---- AOP环绕通知
323232三个人个地方司法发送哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
- 带"签名"的请求接口实现
废话少说,直接上代码(⊙﹏⊙) class Program { //签名证书 public static X509Certificate2 cerSigneCert; private static c ...