prologue

这个题这么水的一个板子题。

analysis

这个题目我们正反建两条边,在跑欧拉回路的时候,看这个边是不是被走过,走过就不走,跳过这个边。如果没走,就走这条边并且标记这个边走过了。

code time

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rl register ll const ll N = 2e4 + 10, M = 1e5 + 10; ll n, m; ll tot, ne[M], e[M], h[N], ans[M], cnt; bool rm[M]; inline void add(ll a, ll b)
{
ne[++tot] = h[a], h[a] = tot, e[tot] = b;
} inline void dfs(ll u)
{
for(rl i=h[u]; ~i; i = ne[i])
{
if(rm[i]) continue; rm[i] = true; ll v = e[i];
dfs(v);
}
ans[++cnt] = u;
} int main()
{
freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
cin >> n >> m; memset(h, -1, sizeof h); for(rl i=1; i <= m; ++ i)
{
ll a, b;
cin >> a >> b;
add(a, b), add(b, a);
} dfs(1); for(rl i=cnt; i; -- i) cout << ans[i] << endl;
return 0;
}

P6066 [USACO05JAN] Watchcow S的更多相关文章

  1. [欧拉] poj 2230 Watchcow

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

  2. POJ2230 Watchcow【欧拉回路】

    Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6172Accepted: 2663 Special Judge ...

  3. POJ22230 Watchcow (欧拉回路)

    Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6477   Accepted: 2823   Specia ...

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

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

  5. POJ 2230 Watchcow (欧拉回路)

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

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

  7. POJ 2230 Watchcow 【欧拉路】

    Watchcow Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6336   Accepted: 2743   Specia ...

  8. 欧拉回路输出(DFS,不用回溯!)Watchcow POJ 2230

    Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 8109   Accepted: 3551   Special Judge D ...

  9. POJ 2230 Watchcow

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

  10. POJ 2230 Watchcow 欧拉图

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

随机推荐

  1. 【python基础】类-继承

    编写类时,并非总是要从空白开始.如果要编写的类时另一个现成类的特殊版本,可使用继承.一个类继承另一个类时,它将自动获得另一个类的所有属性和方法 原有的类称为父类,而新类被称为子类.子类继承了其父类的所 ...

  2. 如何在Databricks中使用Spark进行数据处理与分析

    目录 <如何在Databricks中使用Spark进行数据处理与分析> 随着大数据时代的到来,数据处理与分析变得越来越重要.在数据处理与分析过程中,数据的存储.处理.分析和展示是不可或缺的 ...

  3. R语言中的跨平台支持:如何在Windows、MacOS和Linux上使用R语言进行数据分析和可视化

    目录 当今数据科学领域,R语言已经成为了数据分析和可视化的流行工具.R语言具有强大的功能和灵活性,使得它可以在各种不同的平台上运行,包括Windows.MacOS和Linux.因此,本文将介绍R语言中 ...

  4. ASP.NET Core 6框架揭秘实例演示[40]:基于角色的授权

    ASP.NET应用并没有对如何定义授权策略做硬性规定,所以我们完全根据用户具有的任意特性(如性别.年龄.学历.所在地区.宗教信仰.政治面貌等)来判断其是否具有获取目标资源或者执行目标操作的权限,但是针 ...

  5. 如何将PCM格式的原始音频采样数据编码为MP3格式或AAC格式的音频文件?

    一.打开和关闭输入文件和输出文件以及判断输入文件是否读取完毕 //io_data.cpp static FILE* input_file= nullptr; static FILE* output_f ...

  6. 每日一题力扣 1262 https://leetcode.cn/problems/greatest-sum-divisible-by-three/

    . 题解 这道题目核心就算是要知道如果x%3=2的话,应该要去拿%3=1的数字,这样子才能满足%3=0 贪心 sum不够%3的时候,就减去余数为1的或者余数为2的 需要注意 两个余数为1会变成余数为2 ...

  7. C语言。格式化符号

    %s 输出字符串 %d 输出整形数字 %f 输出浮点数数字 %c 输出字符 %x 输出16进制 %04d 输出长度固定的整形数字(0001,0002,....)

  8. 简单认识Promise

    什么是Promise Promise是异步编程的一个解决方案:从语法上讲它是一个对象,可以获取到异步操作的消息,从本意上讲,它是一个承诺,承诺过一段时间后它会给你一个结果.Promise有三种状态:p ...

  9. React报错:You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1).

    错误 解决方案 说白了就是版本过低,升级下就好.或者按照提示卸载掉原来的版本,之后输入临时创建命令即可,如下图所示 参考链接 https://stackoverflow.com/questions/7 ...

  10. 安装 配置 正向 解析 DNS方法

    安装 配置 正向 解析 DNS方法 1,安装dhcp [root@localhost ~]#yum install bind* -y 2,关闭防火墙和selinux [root@localhost ~ ...