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. SpringBoot 拦截器 & 过滤器

    拦截器 Java里的拦截器是动态拦截Action调用的对象,它提供了一种机制可以使开发者在一个Action执行的前后执行一段代码,也可以在一个Action执行前阻止其执行,同时也提供了一种可以提取Ac ...

  2. VSCode中打开NodeJS项目自动切换对应版本的配置

    这几年搞了不少静态站点,有的是Hexo的,有的是VuePress的.由于不同的主题对于NodeJS的版本要求不同,所以本机上不少NodeJS的版本. 关于如何管理多个NodeJS版本,很早之前就写过用 ...

  3. Atcoder ABC244E - King Bombee 题解

    原题: Atcoder ABC244E - King Bombee 题意 给你一张图,从 \(S\) 到 \(T\),经过 \(k\) 条边, 经过 \(X\) 号点偶数次的方案数. 做法 设 \(f ...

  4. 【Jenkins】 GitLab Gitee GitHub 部署

    Jenkins GitLab Gitee GitHub 部署 环境 Jenkins Git Maven Jenkins 部署可参考文章:https://www.cnblogs.com/cxt618/p ...

  5. Hexo博客Next主题bilibili视频Markdown插入文章

    问题及需求 B站视频无广告有弹幕,非常简洁,经常看B站视频,在文章引用B站的视频 在不用插件的情况下用官方的iframe方式引入视频,默认的方式导入视频屏幕会很小 一般我们都是自己改width和hei ...

  6. RabbitMQ 中 exchange、route、queue 的关系

    从 AMQP 协议可以看出,MessageQueue.Exchange 和 Binding 构成了 AMQP 协议的核心,下面我们就围绕这三个主要组件 从应用使用的角度全面的介绍如何利用 Rabbit ...

  7. linux内核编译体验篇(一)

    文章目录 一. 准备环境 二. 获取内核源码 三. 交叉编译工具链的配置 1. 博友们常用安装方法链接 2. 公司常用的交叉工具链使用方法 四. 内核解压以及如何打补丁 五. 内核基本配置 1. 编译 ...

  8. ArrayList按指定大小分割集合

    ArrayList按指定大小分割集合 项目中使用SpringDataJpa的使用,用到了批量操作,发现框架本身有限制,长度不能超过1000,所以就百度了一下,网上都说是分段处理,也有说用OR的,但数据 ...

  9. IIS 应用程序池 PowerShell 脚本更改高级属性的方法

    ## IIS WebAdmin Module Import-Module WebAdministration $AppPool = "mqttService(8011)" $Sit ...

  10. p2:认识requests库的常用方法与实战

    二.全面认识requests库的常用方法 requests是python第三方库安装命令方法如下: pip install requests python的默认的测试用来规则 1.模块名必须以test ...