随笔分类 - 欧拉路
摘要:View Code 1 /* 2 1.先用并差集判断图是否连通 3 2.判断是否存在欧拉路或欧拉回路 4 3.DFS求欧拉路径 5 */ 6 #include<iostream> 7 #include<cstdio> 8 #include<cstring> 9 #include<algorithm> 10 using namespace std; 11 12 const int size = 1005; 13 14 struct nodedge 15 { 16 int e;//单词的最后一个字母 对应的数字 相当于:路径的末端 17 int id
        阅读全文
                
摘要:View Code 1 /* 2 问题:给出一些两端染有颜色木棒, 3 把这些木棒以相同的颜色对接 4 是否能形成一条直线 5 思路: 6 1.输入 以文件结束 7 2.利用字符串hash ,在hash表中存放的 8 是这是第几个端点,也能表明在这位置的端点 9 是否出现过10 3.并查集判断连通性11 4.看是否存在欧拉路 12 13 呵呵,没想到数组开这么大,用了hash记录点 竟然一次过了,欣喜,加油!!! 14 */15 #include<iostream>16 #include<cstdio>1...
        阅读全文
                
摘要:View Code 1 /* 2 思路: 3 把这个无向图看成有向图 4 相当于无向图 的边走两边,同一条边走的方向不同 5 相当于求 有向图的 欧拉回路 6 */ 7 #include<iostream> 8 #include<cstring> 9 using namespace std;10 struct node 11 {12 int b;13 bool flag;14 node *next;15 }E[100010];16 node table[10010];17 int n,m;18 void clur(int x)19 {20 node *p=tab...
        阅读全文
                
                    
                
浙公网安备 33010602011771号