Watchcow
题目大意:
给你一幅连通的图,要求从起点1开始走,要经过每条边刚好两次,并且最终回到1起点。
思路:将无向图转换成有向图求欧拉回路。
#include<cstdio>
#define N 11000
#define M 110000//由于是将无向图转换成有向图,所以边变为原来的两倍。
//因此*2,这个地方调了好几天,满满的都是泪啊。
int n,m;
struct map
{
int tot;
int head[N],v[M],pre[M];
/*
pre[]里存的是a点连得另一个点的编号。
v[]存的是当前边连得b点。
*/
bool f[M];
void addedge(int a,int b)
{
tot++;
v[tot]=b;
pre[tot]=head[a];
head[a]=tot;
}
}G;
void dfs(int now)
{
for (int p=G.head[now];p;p=G.pre[p])
{
if (!G.f[p])
{
G.f[p]=;
dfs(G.v[p]);
}
}
printf("%d\n",now);
}
int main()
{
scanf("%d%d",&n,&m);
for (int i=;i<=m;i++)
{
int a,b;
scanf("%d%d",&a,&b);
G.addedge(a,b);
G.addedge(b,a);
}
dfs();
return ;
}
Watchcow的更多相关文章
- [欧拉] 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 ...
随机推荐
- LA 3263 欧拉定理
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- 实时控制软件第一次作业--CNC软件系统分析
作者:李君威U201310747 一.该系统有哪些强实时功能需求?需要对哪些实时事件进行实时响应,对允许的实时延迟的数量级进行估计. 答:在数控系统中,位置控制.插补计算.紧急控制等严格实时性任务需要 ...
- angular2的管道初体验
ng管道是应用里面比较重要的一个技术,他涉及很多功能 包括排序过滤 废话不说 直接上代码 新建个文件夹吧这个samplepipe.ts放进去 然后 你要做什么 在里面写管道代码 然后在app.modu ...
- Android Dialog触摸对话框外部让其消失的实现方法
方法一: @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent ...
- 我的搜索优化记录(一):中文分词优化IK Analyzer
搜索绝对不仅仅是搭起框架,跑出结果就完成的工作,之后分词.排序等等的优化才是重头戏. 先交代下背景:这个搜索是我一个人负责搭建并优化的项目,主要索引对象为歌曲.歌手MV等等. 使用技术:Lucene. ...
- 概率dp-九度-1546-迷宫问题
题目链接: http://ac.jobdu.com/problem.php?pid=1546 题目意思: 有一个起点S,多个出口E,#代表不能走,每次等概率的随机选择下一个可以行走的位置,求从S到出口 ...
- 从零开始学习jquery (二)
前面我们了解到了如何获取使用jquery,下面我们主要看看jquery的一些语法.基本的语法 $(selector).action(). 美元符号定义 jQuery 选择符(selector)&quo ...
- php declare (ticks = N)
A tick is an event that occurs for every N low-level tickable statements executed by the parser with ...
- codevs 3336 电话网络
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #defin ...
- JY03-HTML/CSS-京东02
---恢复内容开始--- 1. position:absolute 1.1 绝对定位设置定位值为百分比时: 如设置right:50%,即元素右侧外边框距离父盒子右侧始终始终为父盒子宽度的一半. 可以使 ...