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. 如何在long-running task中调用async方法

    什么是 long-running thread long-running task 是指那些长时间运行的任务,比如在一个 while True 中执行耗时较长的同步处理. 下面的例子中,我们不断从队列 ...

  2. 玉 - Sliver

    基操 1.启动服务端 ./sliver-server_linux 2.启用多客户端协同 new-operator --name zha0gongz1 --lhost [serverip] #生成客户端 ...

  3. 记一次线上bug:crontab 被意外清空

    记一次线上bug:crontab 被意外清空 目录 记一次线上bug:crontab 被意外清空 问题概述 问题排查 问题复现 其他测试 总结 又是一次难忘的经历. 问题概述 同事反馈,某台服务器的c ...

  4. Navicat 连接Oracle ORA-28547: connection to server failed, probable Oracle Net admin error

    Navicat 连接 Oracle 报 ORA-03135: connection lost contact ORA-28547: connection to server failed, proba ...

  5. 你知道.NET的字符串在内存中是如何存储的吗?

    毫无疑问,字符串是我们使用频率最高的类型.但是如果我问大家一个问题:"一个字符串对象在内存中如何表示的?",我相信绝大部分人回答不上来.我们今天就来讨论这个问题. 一.字符串对象的 ...

  6. 【go语言】1.1.1 Go 语言的历史和背景

    Go 语言,也被称为 Golang,是一种静态强类型.编译型的开源编程语言.Go 语言的出现是为了解决当下的软件开发问题,特别是大规模软件系统的开发. Go 语言的设计者包括 Robert Gries ...

  7. Power AutoMate: 变量专栏

    背景 本篇对Power AutoMate的变量功能进行记录与讲解 设置变量 拖拽功能块并赋值 测试一些数据类型 测试中发现与程序中的类型,并没有什么差别 截断数字 对浮点数进行一些操作 选择需要操作的 ...

  8. zabbix6.4 邮件告警配置

    1.注意事项 QQ邮箱不支持zabbix6以上邮件配置,报拒绝登录 建议使用163.com网易邮箱地址 2.添加媒介 创建媒介类型-> 3.添加用户 一般情况下,无需创建用户,编辑admin即可 ...

  9. 用 Tensorflow.js 做了一个动漫分类的功能(二)

    前言: 前面已经通过采集拿到了图片,并且也手动对图片做了标注.接下来就要通过 Tensorflow.js 基于 mobileNet 训练模型,最后就可以实现在采集中对图片进行自动分类了. 这种功能在应 ...

  10. RedHat8静默安装was

    前言 was(websphere application server),类似weblogic.tomcat,由IBM开发的一种企业级Java容器. 系统版本:redhat 8.2 was版本:was ...