Coach(并查集)
摘要:DescriptionA programming coach hasnstudents to teach. We know thatnis divisible by3. Let's assume that all students are numbered from1ton, inclusive.Before the university programming championship the coach wants to split all students into groups of three. For some pairs of students we know that
阅读全文
posted @
2013-11-16 19:53
straw_berry
阅读(613)
推荐(0)
Farm Irrigation(并查集)
摘要:Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4479Accepted Submission(s): 1942Problem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these
阅读全文
posted @
2013-10-07 18:25
straw_berry
阅读(260)
推荐(0)
find the most comfortable road
摘要:XX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适度”有特殊要求,即乘坐过程中最高速度与最低速度的差越小乘坐越舒服 ,(理解为SARS的限速要求,flycar必须瞬间提速/降速,痛苦呀 ),但XX星人对时间却没那么多要求。要你找出一条城市间的最舒适的路径。(SARS是双向的)。Input输入包括多个测试实例,每个实例包括:第一行有2个正整数n (1 2 #include 3 #include 4 using
阅读全文
posted @
2013-09-28 10:47
straw_berry
阅读(197)
推荐(0)
HDOJ迷宫城堡(判断强连通 tarjan算法)
摘要:Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5400Accepted Submission(s): 2411Problem Description为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N 2 #include 3 #include 4 #include 5 using namespace std; 6 7 vectoredge[10010];//用邻接表存图; 8 int n,m; 9 int dfn[100.
阅读全文
posted @
2013-09-20 20:58
straw_berry
阅读(444)
推荐(0)
Play on Words(有向图欧拉路)
摘要:Time Limit:1000MSMemory Limit:10000KTotal Submissions:8571Accepted:2997DescriptionSome of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us.There
阅读全文
posted @
2013-08-30 16:51
straw_berry
阅读(222)
推荐(0)
A Simple problem
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2497题意:给出顶点数,边数及节点s,判断s是否包含在所有的环中;思路:并查集的应用,在除s节点以外的节点中,取出有公共源点的节点放到一个集合中,若还能形成环说明s不能经过所有的环,否则s能经过所有的环; 1 #include 2 #include 3 4 int set[10010],n,m,s; 5 6 int find(int x) 7 { 8 if(set[x] != x) 9 set[x] = find(set[x...
阅读全文
posted @
2013-08-29 23:23
straw_berry
阅读(191)
推荐(0)
Colored Sticks (字典树哈希+并查集+欧拉路)
摘要:Time Limit:5000MSMemory Limit:128000KTotal Submissions:27704Accepted:7336DescriptionYou 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 the same c
阅读全文
posted @
2013-08-16 20:07
straw_berry
阅读(546)
推荐(0)
数据结构实验之图论二:基于邻接表的广度优先搜索遍历
摘要:题目描述给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历)输入输入第一行为整数n(0 2 #include 3 #include 4 #include 5 using namespace std; 6 priority_queue, greater >head[100]; 7 queueq; 8 bool vis[110]; 9 int flag;10 void bfs()11 {12 while(!q.empty())13 {14 int cur = q.fro...
阅读全文
posted @
2013-06-29 19:14
straw_berry
阅读(520)
推荐(0)