传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3918

【题解】

每日至少更一题啊qwq凑任务(迷

明显猜个结论:随便搜环就行了

然后搜环姿势错了我也很无奈啊。。。

# include <stdio.h>
# include <string.h>
# include <algorithm>
// # include <bits/stdc++.h> using namespace std; typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int M = + ;
const int mod = 1e9+; # define RG register
# define ST static int n, m;
int head[M], nxt[M], to[M], tot = ;
inline void add(int u, int v) {
++tot; nxt[tot] = head[u]; head[u] = tot; to[tot] = v;
}
inline void adde(int u, int v) {
add(u, v);
add(v, u);
} bool vis[M];
int Final;
int c[M], cn, p[M]; inline void dfs(int x) {
if(p[x] != -) {
printf("%d", x);
for (int i=p[x]+; i<=cn; ++i) {
printf(" %d", c[i]);
p[c[i]] = -;
}
puts("");
cn = p[x];
return;
}
c[++cn] = x;
p[x] = cn;
for (int i=head[x]; i; i=nxt[i]) {
if(vis[i] || vis[i^]) continue;
head[x] = nxt[i];
vis[i] = ;
dfs(to[i]);
if(p[x] == -) break;
}
} int main() {
scanf("%d%d", &n, &m);
for (int i=; i<=m; ++i) {
int u, v; scanf("%d%d", &u, &v);
adde(u, v);
} for (int i=; i<=n; ++i) p[i] = -; for (int i=; i<=tot; i++)
if(!vis[i] && !vis[i^])
dfs(to[i]); return ;
}

最新文章

  1. 【NLP】Tika 文本预处理:抽取各种格式文件内容
  2. ThinkPHP 事务处理 (事务回滚) 、异常处理
  3. Leetcode 4 Median of Two Sorted Arrays 二分查找(二分答案+二分下标)
  4. SQLAlchemy Core插入数据,有好几种方法呢
  5. [ActionScript 3.0] AS3.0 下雨及涟漪效果
  6. 【学习笔记】【C语言】循环结构-for
  7. 支持向量机(SVM)算法的matlab的实现
  8. 通过blktrace, debugfs分析磁盘IO
  9. 【HDU 3435】 A new Graph Game (KM|费用流)
  10. gettid()和pthread_self()的区别
  11. [转]Delphi调用cmd的两种方法
  12. Mac 下 Scala 平台搭建
  13. JavaScript中遍历数组 最好不要使用 for in 遍历
  14. edu9E. Thief in a Shop
  15. iOS学习——(转)UIResponder详解
  16. Spark_RDD之RDD基础
  17. xlua修复C#的委托事件的时候,需要提前做好配置
  18. linux测试工程介绍(Linux Test Project)
  19. 关于VS2010的帮助文档更改路径
  20. The POSIX API/nss/nscd

热门文章

  1. Hive数据倾斜和解决办法
  2. 还原T4模板执行前的警告对话框
  3. Ubuntu 添加中文字体
  4. Linux-Shell脚本编程-学习-7-总结前面开启后面的学习
  5. Fiddler 4 实现手机App的抓包
  6. bam文件测序深度统计-bamdst
  7. react错误总结
  8. ipfs补充命令
  9. ipfs02
  10. HDU 4588 Count The Carries(数学统计)