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. mysql主从-主主架构设计

    前言: 1. mysql主从.主主复制应用场景很多,其原理主推,从定时根据binlog增量拉取更新 2. 如果主/从机器硬件负载过高,或者网络延迟就会造成同步延迟 3. 延迟是必然,mysql复制同步 ...

  2. Java 文件写入不覆盖的写法

    FileOutputStream o = null; File file = null; FileWriter fw = null; byte[] buff = new byte[]{}; try { ...

  3. Python中使用支付宝支付

    准备 # 支付宝文档 https://opendocs.alipay.com/open/270/105898?pathHash=b3b2b667 # 在沙箱环境下实名认证 https://openho ...

  4. Sentieon | 每周文献-Tumor Sequencing-第三期

    肿瘤测序系列文章-1 标题(英文):The relationship between genetic characteristics and clinical characteristics and ...

  5. 使用GoEasy快速实现Android原生app中的websocket消息推送

    摘要: GoEasy带来了一项令开发者振奋的消息:全面支持Android原生平台!现在,您可以在Android应用中使用最酷炫的实时通信功能,借助GoEasy轻松实现消息的发送和接收.本文将带您领略G ...

  6. 关于ChatGPT与机器时代的展望

    关于 ChatGPT 与机器时代的展望 机器人这一概念,最初不是出自计算机科学家或工程师之手,而是来自于捷克的戏剧家卡雷尔·恰佩克(Karl Capek)在 1920 年编排的一出名为"罗森 ...

  7. vue和servlet 前后端分离 (复习)

    一.vue复习 1.vue的使用步骤: (1)导入vue.js (2)创建除body以外最大的div标签,给定id值 (3)创建vue对象 new Vue({ el:"#app", ...

  8. 从硅谷到北京,百位AI大咖连续两天集聚讨论AI智能和实践

    全球AI大咖齐聚北京,探讨人工智能前沿!百位AI大咖倾力出席,冲向AI大浪潮! AI从业者和企业家们,一场引领未来的科技盛宴即将在北京掀起!我们荣幸地宣布,第四届"数据智能创新与实践人工智能 ...

  9. 使用LaTex添加公式到Hexo博客里

    代码编辑器,强烈推荐使用微软的 VS code,相比Atom开启迅速,使用方便,扩展丰富 第一步: 安装Kramed hexo 默认的渲染引擎是 marked,但是 marked 不支持 mathja ...

  10. G-channel 实现低光图像增强

    G-channel 之前研究低光图像增强时,看到一篇博客,里面介绍了一种方法,没有说明出处,也没有说明方法的名字,这里暂时叫做 G-channel 算法. 博客地址:低照度图像增强(附步骤及源码)_低 ...