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. 6大数据实战系列-sparkSql实战

    sparkSql两个最重要的类SqlContext.DataFrame,DataFrame功能强大,能够与rdd互转换.支持sql操作如sql().where.order.join.groupBy.l ...

  2. 自然语言处理 Paddle NLP - 检索式文本问答-理论

    问答系统(Question Answering System,QA) 是信息检索系统的一种高级形式,它能用准确.简洁的自然语言回答用户用自然语言提出的问题.其研究兴起的主要原因是人们对快速.准确地获取 ...

  3. 了解web网络基础

    TCP/IP 协议:一种规则,规定不同计算机操作系统,硬件之间怎么通信的一种规则 像这样把互联网相关联的协议集合起来总称为TCP/IP协议. TCP/IP分层管理 按照组层次分为以下四层: 应用层:决 ...

  4. 【小小Demo】网页视频通话小🌰子

    工程名 video-call 一个简单的 音视频通话 demo,包含:视频.麦克风.屏幕共享操作. 项目环境 jdk1.8 idea maven springboot 2.1.1.RELEASE we ...

  5. 因为一条DDL,差点搞挂整个系统,这次真的长了教训

    有一次在线上提了一个sql变更,就是下面这条, -- 修改字段的数据类型由varchar(500)变更为text ALTER TABLE t MODIFY COLUMN name text; 提完之后 ...

  6. shell: logging + readlog

    logging #!/bin/bash # a small tool for logging sommething # # 1. read your input # 2. save to logs f ...

  7. tmux 移动窗格

    pre + Ctrl+o:所有窗格向前移动一个位置,第一个窗格变成最后一个窗格 pre + Shift+[:当前窗格与上一个窗格交换位置 pre + Shift+]:当前窗格与下一个窗格交换位置

  8. .NET下数据库的负载均衡“经典方案”(大项目必备,建议收藏)

    [前言] 本文讲述的"数据库负载均衡"方案,为市面上最经典(没有之一),由.NET界骨灰级大佬推出.采用该技术方案的大公司,一年省下了几个亿的支出. [正文] 支持.Net Cor ...

  9. CGLIB动态代理对象GC问题排查

    一.问题是怎么发现的 最近有个新系统开发完成后要上线,由于系统调用量很大,所以先对核心接口进行了一次压力测试,由于核心接口中基本上只有纯内存运算,所以预估核心接口的压测QPS能够达到上千. 压测容器配 ...

  10. Programming abstractions in C阅读笔记:p88-p90

    <Programming Abstractions In C>学习第44天,p88-p90总结. 一.技术总结 1.内存分配 内存分配可以分为:static allocation.auto ...