随笔分类 -  图论

1
摘要:最近公共祖先(Least Common Ancestors)LCA定义:对于有根树T的两个结点u、v,最近公共祖先LCA(T,u,v)表示一个结点x,满足x是u、v的祖先且x的深度尽可能大。另一种理解方式是把T理解为一个无向无环图,而LCA(T,u,v)即u到v的最短路上深度最小的点。离线算法Tarjan: 利用并查集优越的时空复杂度,我们可以实现LCA问题的O(n+Q)算法,这里Q表示询问的次数。Tarjan算法基于深度优先搜索的框架,对于新搜索到 的一个结点,首先创建由这个结点构成的集合,再对当前结点的每一个子树进行搜索,每搜索完一棵子树,则可确定子树内的LCA询问都已解决。其他的LCA. 阅读全文
posted @ 2012-05-08 13:48 lmnx 阅读(259) 评论(0) 推荐(0)
摘要:Junk-Mail FilterTime Limit: 15000/8000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3547Accepted Submission(s): 1079Problem DescriptionRecognizing junk mails is a tough task. The method used here consists of two steps:1) Extract the common characteristics from the in 阅读全文
posted @ 2012-05-03 20:41 lmnx 阅读(892) 评论(0) 推荐(0)
摘要:Cow RelaysTime Limit:1000MSMemory Limit:65536KTotal Submissions:3507Accepted:1388DescriptionFor their physical fitness program,N(2 ≤N≤ 1,000,000) cows have decided to run a relay race using theT(2 ≤T≤ 100) cow trails throughout the pasture.Each trail connects two different intersections (1 ≤I1i≤ 1,0 阅读全文
posted @ 2012-05-03 19:30 lmnx 阅读(1026) 评论(0) 推荐(0)
摘要:Purifying MachineTime Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 1 Accepted Submission(s) : 1Problem DescriptionMike is the owner of a cheese factory. He has 2N cheeses and each cheese is given a binary number from 00...0 to 11...1. To keep his ch 阅读全文
posted @ 2012-05-02 21:49 lmnx 阅读(344) 评论(0) 推荐(0)
摘要:无题II Time Limit : 2000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 11 Accepted Submission(s) : 7 Problem Description 这是一个简单的游戏,在一个n*n的矩阵中,找n个数使得这n个数都在不同的行和列... 阅读全文
posted @ 2012-05-01 21:28 lmnx 阅读(215) 评论(0) 推荐(0)
摘要:Jamie's Contact Groups Time Limit: 15000/7000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 171 Accepted Submission(s): 46 Problem Description Jamie ... 阅读全文
posted @ 2012-05-01 18:46 lmnx 阅读(231) 评论(0) 推荐(0)
摘要:SwapTime Limit : 2000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 3Accepted Submission(s) : 2Special JudgeProblem DescriptionGiven an N*N matrix with each entry equal to 0 or 1. You can swap any two rows or any two columns. Can you find a way to make all the diag 阅读全文
posted @ 2012-05-01 15:55 lmnx 阅读(327) 评论(0) 推荐(0)
摘要:Strategic GameTime Limit : 20000/10000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 4Accepted Submission(s) : 3Problem DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sa 阅读全文
posted @ 2012-05-01 13:22 lmnx 阅读(346) 评论(0) 推荐(0)
摘要:Rain on your ParadeTime Limit : 6000/3000ms (Java/Other)Memory Limit : 655350/165535K (Java/Other)Total Submission(s) : 3Accepted Submission(s) : 2Problem DescriptionYou’re giving a party in the garden of your villa by the sea. The party is a huge success, and everyone is here. It’s a warm, sunny ev 阅读全文
posted @ 2012-05-01 12:30 lmnx 阅读(187) 评论(0) 推荐(0)
摘要:ArbiterTime Limit : 1000/1000ms (Java/Other)Memory Limit : 131072/131072K (Java/Other)Total Submission(s) : 2Accepted Submission(s) : 2Problem DescriptionArbiter is a kind of starship in the StarCraft science-fiction series. The Arbiter-class starship is a Protoss warship specializing in providing p 阅读全文
posted @ 2012-05-01 11:31 lmnx 阅读(296) 评论(0) 推荐(0)
摘要:Taxi Cab SchemeTime Limit : 20000/10000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 3Accepted Submission(s) : 3Problem DescriptionRunning a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick u 阅读全文
posted @ 2012-05-01 10:40 lmnx 阅读(399) 评论(0) 推荐(1)
摘要:I'm Telling the TruthTime Limit : 2000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 2Accepted Submission(s) : 2Problem DescriptionAfter this year’s college-entrance exam, the teacher did a survey in his class on students’ score. There are n students in the cla 阅读全文
posted @ 2012-05-01 10:04 lmnx 阅读(291) 评论(0) 推荐(0)
摘要:Fire Net Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 3 Accepted Submission(s) : 3Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a s... 阅读全文
posted @ 2012-04-30 13:58 lmnx 阅读(285) 评论(0) 推荐(0)
摘要:National Treasures Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 4 Accepted Submission(s) : 3Problem DescriptionThe great hall of the national museum has been robbed few times recently. Everyone is now worried about the security of the treasu... 阅读全文
posted @ 2012-04-30 12:07 lmnx 阅读(1011) 评论(0) 推荐(0)
摘要:Marriage Match IITime Limit : 2000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 6Accepted Submission(s) : 5Problem DescriptionPresumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house 阅读全文
posted @ 2012-04-30 09:22 lmnx 阅读(431) 评论(0) 推荐(0)
摘要:Cat vs. DogTime Limit : 2000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 5Accepted Submission(s) : 5Problem DescriptionThe latest reality show has hit the TV: ``Cat vs. Dog''. In this show, a bunch of cats and dogs compete for the very prestigious Best Pe 阅读全文
posted @ 2012-04-30 09:06 lmnx 阅读(431) 评论(0) 推荐(0)
摘要:The Windy'sTime Limit : 10000/5000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 9 Accepted Submission(s) : 1Problem DescriptionThe Windy's is a world famous toy factory that owns M top-class workshop to make toys. This year the manager receives N orders for t 阅读全文
posted @ 2012-04-29 20:05 lmnx 阅读(162) 评论(0) 推荐(0)
摘要:THE MATRIX PROBLEMTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4096 Accepted Submission(s): 1051 Problem DescriptionYou have been given a matrix CN*M, each element E of CN*M is positive and no more than 1000, The problem is that if there exist 阅读全文
posted @ 2012-04-27 22:31 lmnx 阅读(214) 评论(0) 推荐(0)
摘要:Go DeeperTime Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/65536K (Java/Other)Total Submission(s) : 6 Accepted Submission(s) : 1Problem DescriptionHere is a procedure's pseudocode:go(int dep, int n, int m) begin output the value of dep. if dep < m and x[a[dep]] + x[b[dep]] != c[dep] 阅读全文
posted @ 2012-04-27 20:02 lmnx 阅读(207) 评论(0) 推荐(0)
摘要:AssignmentTime Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 4 Accepted Submission(s) : 2Problem DescriptionLast year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve 阅读全文
posted @ 2012-04-27 18:13 lmnx 阅读(246) 评论(0) 推荐(0)

1