Junk-Mail Filter Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7515    Accepted Submission(s): 2368 Problem Description Recognizing junk mails is a tough task. The method used here consists o…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1878 思路分析:该问题给定一个无向图,要求判断该无向图是否存在欧拉回路:无向图判断存在欧拉回路的两个必要条件:该无向图为连通图且所有的结点的度数为偶数: 代码如下: #include <cstdio> #include <cstring> #include <iostream> using namespace std; + ; int fa[MAX_N]; int link…
欧拉回路Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18576    Accepted Submission(s): 7219 Problem Description欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路.现给定一个图,问是否存在欧拉回路?  Input测试输入包含若干测试用例.每个测试用例的第1…
Colored Sticks Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 27097   Accepted: 7175 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://acm.hdu.edu.cn/showproblem.php?pid=3478 思路分析:该问题需要求是否存在某一个时刻,thief可能存在图中没一个点:将该问题转换为图论问题即为判断该图是否为一个连通图且不为二分图: (1)二分图的性质:对于无向图G=(V, E),如果可以将图中的点划分为两个不相交的点集X与Y = V - X(V为点集),使得图中所有的边邻接的两个点分别存在集合X与集合Y中,则称该图G为二分图: (2) 二分图判定算法:二分图一种判定方法是给图中的每一…
Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2915    Accepted Submission(s): 931 Problem Description Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to…
Dragon Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4384    Accepted Submission(s): 1673 Problem Description Five hundred years later, the number of dragon balls will increase unexpecte…
My little sister had a beautiful necklace made of colorful beads. Two successive beads in the necklace shared a common color at their meeting point. The figure below shows a segment of the necklace: But, alas! One day, the necklace was torn and the b…
点击打开链接 题意:中文题...... 思路:先推断是否能成环,之前以为是有向图,就用了spfa推断,果断过不了自己出的例子,发现是无向图.并查集把,两个点有公共的父节点,那就是成环了,之后便是求最长路了.之前用spfa将权值取反后求最短路,然后结果取正就完事了,仅仅是加个源点0而已,跑一边居然能超时,难道是姿势不正确吗.....,然后用了更暴力的bfs,由于是一个无环的图,所以从一个点出发后.它能走到的点之后便不用再走了,而这个点在bfs中更新距离时每一个点仅仅能入队一次.....这样就快多了…
题意:给定一些木棒,木棒两端都涂上颜色,求是否能将木棒首尾相接,连成一条直线,要求不同木棒相接的一边必须是相同颜色的.   无向图存在欧拉路的充要条件为: ①     图是连通的: ②     所有节点的度为偶数,或者有且只有两个度为奇数的节点. 图的连通可以利用并查集去判断. 度数的统计比较容易. 代码实现 //第一次用指针写trie,本来是用二维数组,发现数组开不下,只好删删改改,改成指针 //做这道题,知道了欧拉回路判定,还有用指针写trie #include <iostream> #i…