POJ 2230 Watchcow 【欧拉路】
Time Limit: 3000MS | Memory Limit: 65536K | |||
Total Submissions: 6336 | Accepted: 2743 | Special Judge |
Description
If she were a more observant cow, she might be able to just walk
each of M (1 <= M <= 50,000) bidirectional trails numbered 1..M
between N (2 <= N <= 10,000) fields numbered 1..N on the farm once
and be confident that she's seen everything she needs to see. But
since she isn't, she wants to make sure she walks down each trail
exactly twice. It's also important that her two trips along each trail
be in opposite directions, so that she doesn't miss the same thing
twice.
A pair of fields might be connected by more than one trail. Find a
path that Bessie can follow which will meet her requirements. Such a
path is guaranteed to exist.
Input
* Lines 2..M+1: Two integers denoting a pair of fields connected by a path.
Output
Lines 1..2M+1: A list of fields she passes through, one per line,
beginning and ending with the barn at field 1. If more than one solution
is possible, output any solution.
Sample Input
4 5
1 2
1 4
2 3
2 4
3 4
Sample Output
1
2
3
4
2
1
4
3
2
4
1
Hint
Bessie starts at 1 (barn), goes to 2, then 3, etc...
Source
POJ 2230 Watchcow 【欧拉路】的更多相关文章
- POJ 2230 (欧拉路)
分析: 基础的欧拉路算法,变化在于要求每条边正向和反向各走一遍. 链式前向星构图,只要标记走过的单向边,边找边输出即可. code #include <iostream> #include ...
- [欧拉] poj 2230 Watchcow
主题链接: http://poj.org/problem? id=2230 Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submi ...
- POJ 2230 Watchcow(欧拉回路:输出点路径)
题目链接:http://poj.org/problem?id=2230 题目大意:给你n个点m条边,Bessie希望能走过每条边两次,且两次的方向相反,让你输出以点的形式输出路径. 解题思路:其实就是 ...
- POJ 2230 Watchcow
Watchcow Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 2 ...
- POJ 2230 Watchcow(有向图欧拉回路)
Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the ...
- POJ 2230 Watchcow (欧拉回路)
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 5258 Accepted: 2206 Specia ...
- POJ 2230 Watchcow && USACO Watchcow 2005 January Silver (欧拉回路)
Description Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to wal ...
- poj 2337(单向欧拉路的判断以及输出)
Catenyms Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11648 Accepted: 3036 Descrip ...
- POJ 2230 Watchcow 欧拉图
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8800 Accepted: 3832 Specia ...
随机推荐
- hdu 5348 MZL's endless loop
给一个无向图(事实上是有向的.可是没有指定边的方向),你须要指定边的方向,使得每一个点入度和出度相差不超过1. 事实上就是找很多条路径.合起来能走完这个图..先统计各个顶点的度.度为奇数必是起点或终点 ...
- PHP 依据IP地址获取所在城市
有这种需求,须要依据用户的IP地址,定位用户所在的城市. 本文记录性文章,无逻辑性.有这样需求的朋友.能够直接拷贝使用.直接上代码,不需赘述. <? php header('Content-Ty ...
- linux中的热插拔和mdev机制
mdev手册(自己翻译的留着看) mdev实现U盘或SD卡的自动挂载 mdev的使用以及mdev.conf的规则配置--busybox linux中的热插拔和mdev机制 关于实现udev/mdev自 ...
- ftp put get 的使用方法
首先:ftp user@ip 登录到远程主机 成功后,输入ls,如下: ftp> ls 可以得到远程主机的本地目录. 一:get命令(从远程主机下载文件到本机): ftp> get (re ...
- ipmitool常用命令
然后查看ip等信息,使用如下命令: ipmitool lan print 远程访问 可使用如下命令尝试: ipmitool -I lanplus -H 10.108.125.227 -U Admini ...
- 本地虚拟机LNMP环境安装
首先上传源码包到linux中(本人上传到根目录中),随意上传能找到即可 一.配置YUM源(如果已经配好就不许要重新配置) 挂载光驱要挂载到/mnt下 Mount /dev/cdrom /mnt ...
- 简洁的一键SSH脚本
这里发一个自己图省事搞的一个批量打通SSH的脚本,可能对于好多朋友也是实用的,是expect+python的一个组合实现,原理非常easy, 使用起来也不复杂,在此还是简单贴出来说说. noscp.e ...
- Android 浏览器文本垂直居中问题
问题描述 在开发中,我们常使用 line-height 属性来实现文本的垂直居中,但是在安卓浏览器渲染中有一个常见的问题,就是对于小于12px的字体使用 line-height 属性进行垂直居中的时候 ...
- JQuery基础知识--方便忘记时查看
第一次写博客,不多说废话,实用为先.如有不对,请多指正. JQuery api 第一步引入JQuery库. <script type="text/javascript" sr ...
- ios8 一些运行问题
iOS10相册相机闪退bughttp://www.jianshu.com/p/5085430b029fiOS 10 因苹果健康导致闪退 crashhttp://www.jianshu.com/p/5 ...