1.题意:给一个无向简单图,问至少几笔画画完所有的边. 2.思路:①先用并查集求出有几个连通分量:②如果连通分量中只有一个结点,那么就是0笔画:③在一个简单无向连通图中,如果没有欧拉回路,至少要用n/2笔画画完所有边,n是奇点个数. 3AC代码一(93ms): #include<cstdio> #include<cstring> #include<set> #include<vector> using namespace std; int n,m; int
Colored Sticks Time Limit: 5000MS Memory Limit: 128000K Total Submissions: 32545 Accepted: 8585 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a st
http://poj.org/problem?id=2513 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of t
这道题主要还是要判断是不是欧拉图 说白了就是能不能这幅图能不能用一笔画下来,那么就可以知道了,如果是一个环状的,说明奇数度就不存在,否则就只能用两个奇数度(起点终点)//我的理解这是 只需要用字典树将单词变为对应的一个数字,然后并查集操作就可以,需要维护一个度变量 #include<stdio.h> #include<string.h> int du[500010],p[500010]; int tot=1; struct tree { tree *next[30]; int id