Watchcow
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 6336   Accepted: 2743   Special Judge

Description

Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the farm and make sure that no evildoers are doing any evil. She begins at the barn, makes her patrol, and then returns to the barn when she's done.

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

* Line 1: Two integers, N and M.

* 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

OUTPUT DETAILS:

Bessie starts at 1 (barn), goes to 2, then 3, etc...

Source

 
      题意分析:有一个农场看守,他每天晚上的工作就是巡视农场并且保证没有坏人破坏农场。 他从谷仓出发去巡视,并且最终会回到谷仓。
他需要每一条路走两遍,并且这两边必须是不同的方向,就是说:这次从u->v,下次就要从v->u。现在保证所给的数据一定存在满足题意的
路径。
 

POJ 2230 Watchcow 【欧拉路】的更多相关文章

  1. POJ 2230 (欧拉路)

    分析: 基础的欧拉路算法,变化在于要求每条边正向和反向各走一遍. 链式前向星构图,只要标记走过的单向边,边找边输出即可. code #include <iostream> #include ...

  2. [欧拉] poj 2230 Watchcow

    主题链接: http://poj.org/problem? id=2230 Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submi ...

  3. POJ 2230 Watchcow(欧拉回路:输出点路径)

    题目链接:http://poj.org/problem?id=2230 题目大意:给你n个点m条边,Bessie希望能走过每条边两次,且两次的方向相反,让你输出以点的形式输出路径. 解题思路:其实就是 ...

  4. POJ 2230 Watchcow

    Watchcow Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 2 ...

  5. POJ 2230 Watchcow(有向图欧拉回路)

    Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the ...

  6. POJ 2230 Watchcow (欧拉回路)

    Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5258   Accepted: 2206   Specia ...

  7. 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 ...

  8. poj 2337(单向欧拉路的判断以及输出)

    Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11648   Accepted: 3036 Descrip ...

  9. POJ 2230 Watchcow 欧拉图

    Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8800   Accepted: 3832   Specia ...

随机推荐

  1. A股市场底部顶部历史数据

    1. A股市场平均市盈率 大顶沪市平均市盈率:66-70倍. A股市场2次大底沪市平均市盈率:12倍-15倍. 大底时的例子. 2005年6月6日上证指数1000点时的14倍市盈率.2008年10月2 ...

  2. 定时执行线程池ScheduledExecutorService的使用

    ScheduledExecutorService progressExecutorService = Executors.newScheduledThreadPool(1); ScheduledFut ...

  3. Atitit.pdf 预览 转换html attilax总结

    Atitit.pdf 预览 转换html attilax总结 1. Swf flash还是html1 2. pdf2htmlEX1 3. iText 5.5.0 发布,Java 的 PDF 操作类库1 ...

  4. Python读取文件文件夹并检索

    import os import os.path f=open("Shouldlist.txt") ShouldList=[] while 1: line =f.readline( ...

  5. xshell 连接腾讯服务器

    1.先关机, 创建秘钥,再绑定主机,下载秘钥保存下来 2. 填写好主机好和端口 3 4.导入刚才下载的文件 记住用户名是ubuntu 不是root!!

  6. java,jquery对json的解析

    json常用于浏览器对服务器的数据传递,所以,我们会经常在浏览器和服务器段对json进行封装和拆装,下面对这些进行简单介绍吧 1,服务器端,也就是java方面,我们用的是 net.sf.json-li ...

  7. 值类型,Nullable类型

    1. 值类型 比如说int吧,是值类型,是个struct,是这样声明的 public struct Int32 : IComparable, IFormattable, IConvertible, I ...

  8. Linux1_Ubuntu的安装

    安装Ubuntu双系统大致有两种方式: 如果是Vmware+linux系统的话,先下载个securable.exe监测本机是否支持虚拟机的安装 1) wubi.exe安装(13.*版本不支持)2) 刻 ...

  9. 44.Android MD5Util

    44.Android MD5Util public class MD5Util { public static String getMD5String(String key) { char hexDi ...

  10. Intellij idea subversion checkout error

    Subversion 1.8 and IntelliJ IDEA 13 Unlike its earlier versions, Subversion 1.8 support uses the nat ...