P6066 [USACO05JAN] Watchcow S
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的更多相关文章
- [欧拉] poj 2230 Watchcow
主题链接: http://poj.org/problem? id=2230 Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submi ...
- POJ2230 Watchcow【欧拉回路】
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6172Accepted: 2663 Special Judge ...
- POJ22230 Watchcow (欧拉回路)
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6477 Accepted: 2823 Specia ...
- POJ 2230 Watchcow(有向图欧拉回路)
Bessie's been appointed the new watch-cow for the farm. Every night, it's her job to walk across the ...
- POJ 2230 Watchcow (欧拉回路)
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 5258 Accepted: 2206 Specia ...
- 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 ...
- POJ 2230 Watchcow 【欧拉路】
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6336 Accepted: 2743 Specia ...
- 欧拉回路输出(DFS,不用回溯!)Watchcow POJ 2230
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8109 Accepted: 3551 Special Judge D ...
- POJ 2230 Watchcow
Watchcow Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 2 ...
- POJ 2230 Watchcow 欧拉图
Watchcow Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8800 Accepted: 3832 Specia ...
随机推荐
- 《系列二》-- 1、BeanFactory.getBean 总览
目录 一句话概括 1 书接上回 2 揭开 doGetBean() 的神秘面纱, 重要操作一览 3 必要的课外知识 3.1 bean 的作用域 Scope 有哪些 3.2 FactoryBean 是什么 ...
- influxdb常用sql总结
本文为博主原创,转载请注明出处: 1.登录influxdb influx -username admin -password "password" 2.查看数据库 ##查看有哪些数 ...
- python中的数据容器
第六章:Python数据容器 数据容器入门 什么是数据容器 一种可以容纳多份数据的数据类型,容纳的每一份数据称之为1个元素,每一个元素,可以是任意类型的数据,如字符串.数字.布尔等. 根据特点的不同分 ...
- Batch Normalization及其反向传播及bn层的作用
笔记: Batch Normalization及其反向传播 重点: 在神经网络中,网络是分层的,可以把每一层视为一个单独的分类器,将一个网络看成分类器的串联.这就意味着,在训练过程中,随着某一层分类器 ...
- JSGRID loaddata显示超级多空行
这个逼问题困扰了我两天了 作为一个主后端的程序员 初体验前端技术栈真的麻之又麻 以防万一 请先确认 是不是和我一个情况 如果是 请往下看 首先 我们需要念一段咒语 json是json string是s ...
- Semantic Kernel Java SDK,为Java应用程序提供AI功能集成
美国时间 2023 年 7 月 19 日,Semantic Kernel 团队在其官方博客[1]上宣布发布 Java 版Semantic Kernel. Samantic Kernel系列的源代码可在 ...
- Java 调用gdal API(二)——栅格裁剪
gdal可以说是GIS数据处理比较好的工具之一,虽然也提供了Java API,但是官方文档确实太过简单,用起来确实太难受,每次都需要去参考对应的C++api,然后在对应使用. 因此小编决定从这篇文章开 ...
- ChatGPT变笨了,好在还有自知之明
大家好,我是老章 好久没有写文章了,顺便向大家汇报一下最近在忙的事情(多数无疾而终): 1 开发了一个IMG2Latex工具(截图一个公式,自动把latex代码塞进剪贴板) 2 开发了一个播客转文字稿 ...
- 开源资产管理系统chemex
目录 项目地址 部署 初始化环境 安装docker.Mariadb 配置数据库 docker 脚本 运行 项目地址 gitee项目链接 部署 参考链接:Centos7使用Docker部署Chemex资 ...
- OceanBase 分布式存储管理
分布式存储管理 分区表管理 定义 把普通的表的数据按照一定的规则划分到不同的区块内,同一区块的数据物理上存储在一起. 每个分区还能按照一定的规则再拆分成多个分区,这种分区表叫做二级分区表. 分区分类 ...