摘要:HDU3966 Aragorn's StoryTime Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 605Accepted Submission(s): 160Problem DescriptionOur protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemi
阅读全文
摘要:SPOJ 2939. Query on a tree VProblem code: QTREE5You are given a tree (an acyclic undirected connected graph) with N nodes. The tree nodes are numbered from 1 to N. We define dist(a, b) as the number of edges on the path from node a to node b.Each node has a color, white or black. All the nodes are b
阅读全文
摘要:SPOJ Problem Set (classical)SPOJ 1487. Query on a tree IIIProblem code: PT07JYou are given a node-labeled rooted tree withnnodes.Define the query (x,k): Find the node whose label isk-th largest in the subtree of the nodex. Assume no two nodes have the same labels.InputThe first line contains one int
阅读全文
摘要:SPOJ Problem Set (classical)SPOJ 913. Query on a tree IIProblem code: QTREE2You are given a tree (an undirected acyclic connected graph) withNnodes, and edges numbered 1, 2, 3...N-1. Each edge has an integer value assigned to it, representing its length.We will ask you to perfrom some instructions o
阅读全文
摘要:SPOJ Problem Set (classical)2666. Query on a tree IVProblem code: QTREE4You are given a tree (an acyclic undirected connected graph) with N nodes, and nodes numbered 1,2,3...,N. Each edge has an integer value assigned to it(note that the value can be negative). Each node has a color, white or black.
阅读全文
摘要:SPOJ Problem Set (classical)1825. Free tour IIProblem code: FTOUR2After the success of 2nd anniversary (take a look at problemFTOURfor more details), this 3rd year, Travel Agent SPOJ goes on with another discount tour.The tour will be held onICPCisland, a miraculous one on the Pacific Ocean. We list
阅读全文
摘要:POJ1741 TreeTime Limit:1000MSMemory Limit:30000KTotal Submissions:6232Accepted:1770DescriptionGive a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v.Give an integer k,for every pair (u,v) of vertices is called valid
阅读全文
摘要:POJ3237 TreeTime Limit:5000MSMemory Limit:131072KTotal Submissions:2158Accepted:574DescriptionYou are given a tree withNnodes. The tree’s nodes are numbered 1 throughNand its edges are numbered 1 throughN− 1. Each edge is associated with a weight. Then you are to execute a series of instructions on
阅读全文
摘要:Country FTime Limit:2 Seconds Memory Limit:32768 KBAs you know, in aTreethere is exactly one path between two nodes. AForestconsists of one or more Trees. Country F hasNcities, some cities are connected by roads, and these cites form a Forest withat least two trees.The king of country F is a man wit
阅读全文