2070 爱情之路

 时间限制: 1 s
 空间限制: 128000 KB
 题目等级 : 钻石 Diamond
 
 
 
题目描述 Description

yh非常想念他的女朋友小y,于是他决定前往小y所在的那块大陆。

小y所在的大陆共有n个城市,m条双向路,每条路连接一个或两个城市。经过一条路ei需要耗费时间ti。此外,每条路均有一个特定标识,为’L’,’O’,’V’,’E’,中的某个字母。yh从1号城市出发,前往位于n号城市的小y所在处。

为了考验yh,小y规定,yh必须按照‘L’->’O’->’V’->’E’->’L’->’O’->’V’->’E’->.... 的顺序选择路,且所走的第一条路是’L’,最后一条路是’E’,每走完一个完整的’LOVE’算是通过一次考验

在不违背小y要求的前提下,yh想花费最少的时间到达小y的所在地,同在此时间内完成最多次考验。你能帮yh算出,他最少要花多久到达城市n,完成多少次考验呢?

输入描述 Input Description

第一行为两个整数n,m表示有n个城市,m条双向路。

第2行到第m+1行,每行有3个整数x,y,t和一个字符char,城市x,y之间有路,通过这条路花费的时间为t,这条路的特殊标志为 char。

输出描述 Output Description

输出1行,两个整数表示yh到达城市n花费的最少时间和该时间内通过的最多次考验数,如果不能到达则输出’HOLY SHIT!’

样例输入 Sample Input

【样例输入1】

4 4

1 2 1 L

2 1 1 O

1 3 1 V

3 4 1 E

【样例输入2】

4 4

1 2 1 L

2 3 1 O

3 4 1 V

4 1 1 E

样例输出 Sample Output

【样例输出1】

4 1

【样例输出2】

HOLY SHIT!

数据范围及提示 Data Size & Hint

对于100%数据,1≤n≤1314,0≤M≤13520

思路:

  spfa最短路;

  每个点都拆成4个状态;

来,上代码:

#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> #define maxn 20005
#define maxm 200005 using namespace std; struct sp {
int t,now;
}; struct EdgeType {
int v,w,e,type;
};
struct EdgeType edge[maxn<<]; int if_z,n,m,dis[][maxn],cnt,head[maxn],times[][maxn],tot; char Cget; bool if_[][maxn]; inline void in(int &now)
{
now=,if_z=,Cget=getchar();
while(Cget>''||Cget<'')
{
if(Cget=='-') if_z=-;
Cget=getchar();
}
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
now*=if_z;
return ;
} struct sp node(int t,int now)
{
sp pos_;
pos_.t=t,pos_.now=now;
return pos_;
} int main()
{
in(n),in(m);
int u,v,w,t;
while(m--)
{
in(u),in(v),in(w);cin>>Cget;
if(Cget=='L') t=;
if(Cget=='O') t=;
if(Cget=='V') t=;
if(Cget=='E') t=;
edge[++cnt].v=v,edge[cnt].e=head[u],edge[cnt].w=w,edge[cnt].type=t,head[u]=cnt;
edge[++cnt].v=u,edge[cnt].e=head[v],edge[cnt].w=w,edge[cnt].type=t,head[v]=cnt;
}
memset(dis,/,sizeof(dis));
dis[][]=,if_[][]=true;
queue<struct sp>que;que.push(node(,));
while(!que.empty())
{
sp pos=que.front();
if_[pos.t][pos.now]=false;que.pop();
int to=(pos.t%)+;
for(int i=head[pos.now];i;i=edge[i].e)
{
if(edge[i].type==to&&edge[i].w+dis[pos.t][pos.now]<dis[to][edge[i].v])
{
dis[to][edge[i].v]=dis[pos.t][pos.now]+edge[i].w;
// if(to==4) times[edge[i].v]=max(times[edge[i].v],times[pos.now]+1);
// if(to==4) times[to][edge[i].v]=max(times[to][edge[i].v],times[pos.t][pos.now]+1);
times[to][edge[i].v]=times[pos.t][pos.now]+;
if(!if_[to][edge[i].v])
{
que.push(node(to,edge[i].v));
if_[to][edge[i].v]=true;
}
}
else if(edge[i].type==to&&edge[i].w+dis[pos.t][pos.now]==dis[to][edge[i].v])
{
times[to][edge[i].v]=max(times[to][edge[i].v],times[pos.t][pos.now]+);
if(!if_[to][edge[i].v])
{
que.push(node(to,edge[i].v));
if_[to][edge[i].v]=true;
}
}
}
if(tot==) tot++,dis[][]=0x7ffffff;
}
if(dis[][n]>||times[][n]<) cout<<"HOLY SHIT!";
else cout<<dis[][n]<<" "<<times[][n]/;
cout<<endl;
return ;
}

AC日记——爱情之路 codevs 2070的更多相关文章

  1. AC日记——接龙游戏 codevs 1051

    1051 接龙游戏  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond       题目描述 Description 给出了N个单词,已经按长度排好了序.如果 ...

  2. AC日记——松江1843路 洛谷七月月赛

    松江1843路 思路: 三分: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #define ...

  3. AC日记——地鼠游戏 codevs 1052

    1052 地鼠游戏  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description 王钢是一名学习成绩优异的学生,在平 ...

  4. AC日记——鬼谷子的钱袋 codevs 2998

    2998 鬼谷子的钱袋 2006年省队选拔赛湖南  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master    题目描述 Description 鬼谷子非常聪明,正 ...

  5. AC日记——舒适的路线 codevs 1001 (并查集+乱搞)

    1001 舒适的路线 2006年  时间限制: 2 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description Z小镇是 ...

  6. AC日记——逃跑的拉尔夫 codevs 1026 (搜索)

    1026 逃跑的拉尔夫  时间限制: 1 s    空间限制: 128000 KB    题目等级 : 黄金 Gold 题解       题目描述 Description   年轻的拉尔夫开玩笑地从一 ...

  7. AC日记——自然数和分解 codevs 2549

    自然数和分解 思路: 水题: 代码: #include <bits/stdc++.h> using namespace std; ][]; int main() { cin>> ...

  8. AC日记——郁闷的出纳员 codevs 1286

    郁闷的出纳员 思路: 设工资下限为ko,然后ko--(因为要小于工资下限): 设cur为记录工资增长,降低: 设第i个人的工资为pos: 对应的四种操作: 插入:cur-pos-ko: 增长:cur- ...

  9. AC日记——营业额统计 1296 codevs

    1296 营业额统计 2002年  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master 题解  查看运行结果     题目描述 Description Tiger ...

随机推荐

  1. mysql 在线添加字段

    使用工具pt-online-schema-change #! /bin/bash stime=`date +%s` echo "增加字段开始测试时间为:`date +%H:%M:%S`&qu ...

  2. MyBatis逆向工程中的Mapper接口以及Example的实例函数及详解

    一.mapper接口中的方法解析 mapper接口中的函数及方法 方法 功能说明 int countByExample(UserExample example) thorws SQLException ...

  3. CSS基础:block,inline和inline-block

    css的display属性是前端开发中非常常见的属性,本文简单介绍下其中比较常用的属性值,即block.inline和inline-block. HTML组件中呈现一片空白区域的组件都可当盒模型(bo ...

  4. redis代理集群(Twemproxy)(1)

    redis主从+哨兵模式只解决了读的分布式操作,大大提高了性能:但是写操作,只有主主机器才能进行,从机器无法进行写操作.此时,Twemproxy也就出现了. 这个模式单纯的安装有些复杂,需要引入很多的 ...

  5. i2c drivers

    Linux设备驱动程序架构分析之一个I2C驱动实例   转载于:http://blog.csdn.net/liuhaoyutz 内核版本:3.10.1   编写一个I2C设备驱动程序的工作可分为两部分 ...

  6. Page-Object思想

    为什么要使用page-object 集中管理元素对象 集中管理一个page内的公共方法 后期维护方便 集中管理元素对象 实现方法: 调用方法: WebElement element = dri ...

  7. 串口编程的相关API函数

    用户使用函数CreateFile()创建与指定串口相关联的文件,然后可以使用该函数返回的文件句柄进行串口参数设置.• 01 HANDLE hModem; //定义串口句柄02 hModem=Creat ...

  8. 2019 study list

    分析工具: (1)SQL   select from   where   group by having   order by   limit   运算符(算数运算符+-*/.比较运算符>< ...

  9. org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误

    最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...

  10. 如何用treap写luogu P3391

    treap大法好!!! splay什么的都是异端 --XZZ 先%FHQ为敬 (fhq)treap也是可以搞区间翻转的 每次把它成(1~L-1)(L~R)(R+1~n)三块然后打标记拼回去 对于有标记 ...