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. Trie|如何用字典树实现搜索引擎的关键词提示功能

    Trie字典树 Trie字典树又称前缀树,顾名思义,是查询前缀匹配的一种树形数据结构 可以分为插入(创建) 和 查询两部分.参考地址极客时间 下图为插入字符串的过程: 创建完成后,每个字符串最后一个字 ...

  2. 隐藏VS2013的反馈、通知和登录按钮

    Visual Studio 2013的右上角有反馈.通知.登录.快速启动等按钮,在VS2013中没有选项可以设置为隐藏. 打开注册表(开始 -> 运行 -> regedit),展开到以下路 ...

  3. Unity UGUI——提供可视功能的UI组件(Text)

    基本属性介绍 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTXJfQUhhbw==/font/5a6L5L2T/fontsize/400/fill/I0J ...

  4. C和C++格式转换

    一.引用参数和指针的转换 标准C不支持引用参数,对此需进行转换.下面以bo1-1.cpp和bo1-1.c中DestroyTriplet()函数为例来说明这种转换. bo1-1.cpp中含有引用参数的函 ...

  5. python操作Excel读写--使用xlrd (转)

    (转自:http://www.cnblogs.com/lhj588/archive/2012/01/06/2314181.html) 一.安装xlrd模块 到python官网下载http://pypi ...

  6. php序列化与反序列化

    php序列化简单来说就是 把复杂的数据类型压缩到一个字符串中php对象转换成字符串,反序列化就是把变量转换成对象 一般来说  当把这些序列化的数据放在URL中在页面之间会传递时,需要对这些数据调用ur ...

  7. 在Hierarchy面板隐藏物体

    PlantObjPreview.hideFlags = HideFlags.HideInHierarchy;

  8. APNS的推送机制 3

    APNS的推送机制 首先我们看一下苹果官方给出的对iOS推送机制的解释.如下图 Provider就是我们自己程序的后台服务器,APNS是Apple Push Notification Service的 ...

  9. thinkPHP5.0的学习研究【基础】

    2017年6月19日13:25:56 基础:1.ThinkPHP5的环境要求如下: PHP >= 5.4.0        PDO PHP Extension        MBstring P ...

  10. 百度地图SnapshotReadyCallback截屏

    今天碰到了地图截图的功能,不太会,查查资料知道怎么弄了,跟大家分享一下 直接上代码,弄了一个方法,将截取的图片上传至服务器,返回给我们图片路径 //获取地图截图 private void getscr ...