随笔分类 -  DFS

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5424/*对于一个连通图,有N个顶点,如果有N条边,那么肯定有环因为N个点如果不成环最多N-1条边。。。然后找最小度的点DFS就行。。。 *//***********************************... 阅读全文
posted @ 2015-08-31 19:36 Painting、时光 阅读(140) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4324/*搜索一个三角形,用vector+vis来减少复杂度*//************************************************* Author :Powatr* C... 阅读全文
posted @ 2015-08-25 15:15 Painting、时光 阅读(142) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1426/*暴力发现最大数目不超过19位,开unsigned long long 水过*//************************************************* Author :Powatr* Creat... 阅读全文
posted @ 2015-08-09 16:07 Painting、时光 阅读(132) 评论(0) 推荐(0)
摘要:Problem DescriptionAs we all kown, MZL hates the endless loop deeply, and he commands you to solve this problem to end the loop.You are given an undir... 阅读全文
posted @ 2015-08-06 20:57 Painting、时光 阅读(248) 评论(0) 推荐(0)
摘要:There is an integeraandnintegersb1,…,bn. After selecting some numbers fromb1,…,bnin any order, sayc1,…,cr, we want to make sure thatamodc1modc2mod…mod... 阅读全文
posted @ 2015-08-02 15:27 Painting、时光 阅读(109) 评论(0) 推荐(0)
摘要:There arenpeople andmpairs of friends. For every pair of friends, they can choose to become online friends (communicating using online applications) o... 阅读全文
posted @ 2015-07-23 21:12 Painting、时光 阅读(117) 评论(0) 推荐(0)
摘要:Mr. Kitayuta has just bought an undirected graph consisting ofnvertices andmedges. The vertices of the graph are numbered from 1 ton. Each edge, namel... 阅读全文
posted @ 2015-07-22 15:02 Painting、时光 阅读(233) 评论(0) 推荐(0)
摘要:DZY loves chemistry, and he enjoys mixing chemicals.DZY hasnchemicals, andmpairs of them will react. He wants to pour these chemicals into a test tube... 阅读全文
posted @ 2015-07-22 14:05 Painting、时光 阅读(196) 评论(0) 推荐(0)
摘要:/*大意:给出m给不认识关系,要把他们分成两组,每组人都要认识用一个col来记录是否相邻,如果出现奇数环会使得col[v] != 3 - color,不能省如果不存在边,特判,分一个人过去*/#include #include #include #include using namespace st... 阅读全文
posted @ 2015-07-20 20:31 Painting、时光 阅读(144) 评论(0) 推荐(0)
摘要:Vasya has a very beautiful country garden that can be represented as ann × mrectangular field divided inton·msquares. One beautiful day Vasya remember... 阅读全文
posted @ 2015-07-20 14:33 Painting、时光 阅读(202) 评论(0) 推荐(0)
摘要:由于计划生育的实行,我们以及将来几代人都会是独生子女,即每对夫妇只会有一个孩子。那么给你XXXX年某人的一张树形族谱,你能指出其中任意两人的关系吗?Input输入数据第一行一个整数T表示有T组数据。每组数据第一行一个正整数N (2 #include#include#includeusing name... 阅读全文
posted @ 2015-07-18 16:14 Painting、时光 阅读(217) 评论(0) 推荐(0)
摘要:You are givennk-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number wa... 阅读全文
posted @ 2015-07-15 00:16 Painting、时光 阅读(410) 评论(0) 推荐(0)
摘要:Two bored soldiers are playing card war. Their card deck consists of exactlyncards, numbered from1ton,all values are different. They divide cards betw... 阅读全文
posted @ 2015-05-26 18:12 Painting、时光 阅读(156) 评论(0) 推荐(0)
摘要:Description把前n个正整数摆成1个环,如果环中所有相邻的2个数之和都是1个素数,该环称为1个n项素数和环。 输入1个整数n,输出共有多少种Input输入一个正整数nOutput输出环的个数,要求环的第一个数字是1Sample Input4Sample Output2HINT大意:回溯,要会... 阅读全文
posted @ 2015-05-19 16:58 Painting、时光 阅读(458) 评论(0) 推荐(0)
摘要:Description在n*n(1 #include#includeusing namespace std;int tot,n;int c[100];int vis[100];int path[100];bool flag; void dfs(int cur){ if(cur == n + 1... 阅读全文
posted @ 2015-05-17 20:26 Painting、时光 阅读(388) 评论(0) 推荐(0)
摘要:Description多组测试数据 给你一棵树,n个点(n#include#include#includeusing namespace std;const int maxn = 10100;int mark[maxn],cot[maxn];vector G[10100];int dfs(int r... 阅读全文
posted @ 2015-05-14 00:10 Painting、时光 阅读(169) 评论(0) 推荐(0)
摘要:DescriptionLet us define a regular brackets sequence in the following way:Empty sequence is a regular sequence.If S is a regular sequence, then (S) an... 阅读全文
posted @ 2015-05-12 21:44 Painting、时光 阅读(127) 评论(0) 推荐(0)
摘要:DescriptionOnce upon a time an Eagle made a nest on the roof of a very large building. Time went by and some eggs appeared in the nest. There was a su... 阅读全文
posted @ 2015-05-12 19:29 Painting、时光 阅读(276) 评论(0) 推荐(0)
摘要:DescriptionThe owner of a casino for New Russians has a very refined sense of beauty. For example, after a game there remain two piles with the same n... 阅读全文
posted @ 2015-05-12 14:32 Painting、时光 阅读(190) 评论(0) 推荐(0)
摘要:DescriptionIf two people were born one after another with one second difference and one of them is a child, then the other one is a child too. We get ... 阅读全文
posted @ 2015-05-07 14:55 Painting、时光 阅读(180) 评论(0) 推荐(0)