不吐槽。。

  1. #include <iostream>
  2. #include <map>
  3. #include <queue>
  4.  
  5. //无语的水题。节哀吧。且这道题不严谨,因为没说是无环。算了,不吐槽了。优先队列+BFS
  6.  
  7. using namespace std;
  8. const int inf=;
  9. const int MAxN=;
  10. const int MAXM=;
  11. typedef struct ei{
  12. int v;
  13. int begin;
  14. int ends;
  15. }edge;
  16. vector<edge>Edge[MAxN];
  17. typedef struct ci{
  18. int city;
  19. int litre;
  20. int artime;
  21. bool operator<(const ci &A)const {
  22. return (litre>A.litre) ;
  23. }
  24. }City;
  25. City tmp,pushed;
  26. int m,tot;
  27. int start_city,end_city;
  28. int LITRES;
  29.  
  30. void init(){
  31. for(int i=;i<MAxN;i++)
  32. Edge[i].clear();
  33. }
  34.  
  35. void addedge(int u,int v,int be,int en){
  36. Edge[u].push_back((edge){v,be,en});
  37. }
  38.  
  39. bool slove(){
  40. int now; int tmptime,pushtime;
  41. priority_queue<City>que;
  42. tmp.city=start_city; tmp.artime=; tmp.litre=;
  43. que.push(tmp);
  44. while(!que.empty()){
  45. tmp=que.top();
  46. que.pop();
  47. now=tmp.city;
  48. if(now==end_city){
  49. LITRES=tmp.litre;
  50. return true;
  51. }
  52. for(int e=;e<Edge[now].size();e++){
  53. tmptime=tmp.artime; pushtime=Edge[now][e].begin;
  54. int used=tmp.litre;
  55. if(pushtime<tmptime){
  56. used++;
  57. }
  58. que.push((City){Edge[now][e].v,used,Edge[now][e].ends});
  59. }
  60. }
  61. return false;
  62. }
  63.  
  64. int main(){
  65. int T; int from,to; int Cas=;
  66. string start,ends; int stt,edt,waste;
  67. cin>>T;
  68. while(T--){
  69. Cas++;
  70. init();
  71. map<string,int>citys;
  72. cin>>m;
  73. for (int i = ; i <= m; i++)
  74. {
  75. cin >> start >> ends >> stt >> waste;
  76. if (citys.find(start) == citys.end())
  77. {
  78. from = citys.size();
  79. citys[start] = from;
  80. }
  81. else
  82. from = citys[start];
  83.  
  84. if (citys.find(ends) == citys.end())
  85. {
  86. to = citys.size();
  87. citys[ends] = to;
  88. }
  89. else
  90. to = citys[ends];
  91. if(((stt>=)||(stt<=&&stt>=))){ //我调了一天,把自己原来写的改得面目全非,对着别人的改啊改
  92. //都几乎改成别人的了,终于,一道水题,让我过了。当我把(stt>=18&&stt<=24)改成(stt>=18)之后,过了。哈哈哈
  93. //坑爹的测试数据啊。肯定是有测试数据超过了24。尼玛,还我一早上的时间,kao,一万个操。。 还以为是我的算法错了呢
  94. //原来是测试数据坑..
  95. if(stt<=)
  96. stt+=;
  97. edt=stt+waste;
  98. if(edt<=){
  99. Edge[from].push_back((edge){to,stt,edt});
  100. }
  101. }
  102.  
  103. }
  104. cin>>start>>ends;
  105. if(start==ends){
  106. cout << "Test Case " << Cas << "." << endl;
  107. cout << "Vladimir needs 0 litre(s) of blood." << endl;
  108. continue;
  109. }
  110. if(citys.find(start)==citys.end()
  111. ||citys.find(ends)==citys.end()){
  112. cout << "Test Case " << Cas << "." << endl;
  113. cout << "There is no route Vladimir can take." << endl;
  114. continue;
  115. }
  116. start_city=citys[start]; end_city=citys[ends];
  117. if(slove()){
  118. cout << "Test Case " << Cas << "." << endl;
  119. cout << "Vladimir needs " << LITRES << " litre(s) of blood." << endl;
  120. }
  121. else {
  122. cout << "Test Case " << Cas << "." << endl;
  123. cout << "There is no route Vladimir can take." << endl;
  124. }
  125. }
  126. return ;
  127. }

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. 复习--二叉树&&树

    树是一种很常用的数据结构,日后的学习中会经常碰到运用树的知识. //构造二叉树#include<cstdio> #include<iostream> #include<a ...

  2. django自带权限控制系统的使用和分析

    1.django的权限控制相关表及其相互间的关系: django的所有权限信息存放在auth_permission表中,用户user和用户组group都可以有对应的权限permission.分别存放在 ...

  3. git拉取远端改变,但是不覆盖本地的修改

    1.git stash 2.git  fetch weixin-old-remote 3.git rebase weixin-old-remote/main151028_wxpay_main15100 ...

  4. aspectC++常用命令

    常用命令:1.ag++ main.cc //在工程目录下产生编译后的exe2.ag++ main.cc --weave_only //产生.acc 纯c++文件3.ag++ main.cc --gen ...

  5. Spring Boot 打 war 包的步骤

    ## Spring Boot 打 war 包的步骤 1. 添加 spring-boot-start-tomcat 的 provided 依赖 ``` <dependency> <gr ...

  6. ThinkPHP3.2.3扩展之自动分词获取关键字

    ThinkPHP自动获取关键词调用在线discuz词库 先按照下图路径放好插件 /** * 自动获取关键词(调用第三方插件) * @return [type] [description] * www. ...

  7. CAS配置(1)SSL证书配置

    一.配置源码 源码配置稍后提供 二.系统环境安装 安装JDK配置,版本>=1.7 环境变量配置(参考): JAVA_HOME=C:\Program Files x86)\Java\jdk1.7. ...

  8. python 字符编码的两种方式写法:# coding=utf-8和# -*- coding:utf-8 -*-

    python运行文件是总会出现乱码问题,为了解决这个问题,在文件开头加上: # coding=utf-8 或者 # -*- coding:utf-8  -*- # coding=<encodin ...

  9. Spring的AOP机制---- AOP环绕通知---- AOP环绕通知

    323232三个人个地方司法发送哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈

  10. 带"签名"的请求接口实现

    废话少说,直接上代码(⊙﹏⊙) class Program { //签名证书 public static X509Certificate2 cerSigneCert; private static c ...