POJ 1041问题描述
Description
The streets in Johnny's town were named by integer numbers from 1 to n, n < 1995. The junctions were independently named by integer numbers from 1 to m, m <= 44. No junction connects more than 44 streets. All junctions in the town had different numbers. Each street was connecting exactly two junctions. No two streets in the town had the same number. He immediately started to plan his round trip. If there was more than one such round trip, he would have chosen the one which, when written down as a sequence of street numbers is lexicographically the smallest. But Johnny was not able to find even one such round trip.
Help Johnny and write a program which finds the desired shortest round trip. If the round trip does not exist the program should write a message. Assume that Johnny lives at the junction ending the street appears first in the input with smaller number. All streets in the town are two way. There exists a way from each street to another street in the town. The streets in the town are very narrow and there is no possibility to turn back the car once he is in the street
Input
Output
Sample Input
1 2 1
2 3 2
3 1 6
1 2 5
2 3 3
3 1 4
0 0
1 2 1
2 3 2
1 3 3
2 4 4
0 0
0 0
Sample Output
1 2 3 5 4 6
Round trip does not exist.
POJ 1041问题描述的更多相关文章
- poj 1041(欧拉回路+输出字典序最小路径)
题目链接:http://poj.org/problem?id=1041 思路:懒得写了,直接copy吧:对于一个图可以从一个顶点沿着边走下去,每个边只走一次,所有的边都经过后回到原点的路.一个无向图存 ...
- [POJ 1041] John's Trip
[题目链接] http://poj.org/problem?id=1041 [算法] 欧拉回路[代码] #include <algorithm> #include <bitset&g ...
- poj 1041 John's trip——欧拉回路字典序输出
题目:http://poj.org/problem?id=1041 明明是欧拉回路字典序输出的模板. 优先队列存边有毒.写跪.学习学习TJ发现只要按边权从大到小排序连边就能正常用邻接表了! 还有一种存 ...
- POJ 1528问题描述
Description From the article Number Theory in the 1994 Microsoft Encarta: ``If a, b, c are integers ...
- POJ 1039问题描述
Description The GX Light Pipeline Company started to prepare bent pipes for the new transgalactic li ...
- POJ 1035题目描述
Description You, as a member of a development team for a new spell checking program, are to write a ...
- POJ 1032问题描述
Description New convocation of The Fool Land's Parliament consists of N delegates. According to the ...
- POJ 1028题目描述
Description Standard web browsers contain features to move backward and forward among the pages rece ...
- poj 1041 John's trip 欧拉回路
题目链接 求给出的图是否存在欧拉回路并输出路径, 从1这个点开始, 输出时按边的升序输出. 将每个点的边排序一下就可以. #include <iostream> #include < ...
随机推荐
- Qt5.4 VS2010 Additional Dependancies
Go to Linker -> General -> Additional LIbrary Directories: qtmaind.libQt5Cored.libQt5Guid.libQ ...
- Java主要有那几种文件类型,各自作用
java提供了两类数据类型:基本类型,引用类型. 1.基本类型包括:boolean ,byte,char,int,short,float,long,double,值得注意的是:在原始数据类型中,除了b ...
- 4.用文本编辑器输入课堂上练习的Hello.java,并在JDK环境下编译和运行。请将程序编译、运行的结果截图,填入下框中。
一开始报错是因为在文本框了的:用的是中文下的,应该用英文下的;
- lucene 建立索引的过程
时间 -- :: CSDN博客 原文 http://blog.csdn.net/caohaicheng/article/details/ 看lucene主页(http://lucene.apach ...
- 一个Java方法覆盖的小问题
class SuperClass{ public SuperClass() { System.out.println("superclass "); show(); } publi ...
- ZooKeeper应用场景介绍
ZooKeeper是一个高可用的分布式数据管理与系统协调框架.维护着一个树形层次结构,书中的节点被称为znode.znode可以用来存储数据,并且有一个与之相关联的ACL(权限),znode不能大于1 ...
- Android消息处理机制
Android消息处理机制 Android应用程序消息处理机制(深入到native,实际由管道实现-pipe&epoll)
- NetBeans 8.0 连接远程服务器
step: ① 新建项目 -- PHP -- 来自远程服务器的 PHP 应用程序 -- 下一步 ② 名称和位置 项目名称:自己取: 源文件夹:通过 “浏览” 选择本地项目文件夹.注意文件夹内不能有 n ...
- php preg_match_all 和 str_replace 替换图片链接
需求:在 a 网站的后台添加一片文章,需要同步到 b 网站(两个网站数据库在同一台服务器). 思路是添加文章时,除了往 b 网站的数据库中添加数据外,再往 a 网站的数据库中添加数据. a 添加文章的 ...
- centos7 设置中文
查看系统版本[root@webtest76 ~]# cat /etc/redhat-releaseCentOS Linux release 7.0.1406 (Core) [root@localhos ...