摘要:
输入样例: 4 5 1 2 1 4 2 3 2 4 3 4 输出样例: 1 2 3 4 2 1 4 3 2 4 1 直接对边访问数组进行维护的同时,一次dfs就能走完两遍。 没想明白为啥欧拉回路可以这样做。 1 #include<bits/stdc++.h> 2 using namespace st 阅读全文
posted @ 2024-11-01 20:24
Coder何
阅读(24)
评论(0)
推荐(0)
摘要:
找到有几张连通图即可解决问题。 DFS: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 int graph[1005][1005] = {0}; 5 bool visited[1005] = {false}; 6 voi 阅读全文
posted @ 2024-11-01 19:28
Coder何
阅读(8)
评论(0)
推荐(0)