07 2013 档案
摘要:DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quickly k-th order statistics in the array segment.That is, given an array a[1...n] of differ
阅读全文
摘要:DescriptionThe Contortion Brothers are a famous set of circus clowns, known worldwide for their incredible ability to cram an unlimited number of them...
阅读全文
摘要:DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of G, say T = (V', E'), with the following properties:1. V' = V.2. T is connected
阅读全文
摘要:DescriptionOnce in a forest, there lived N aggressive monkeys. At the beginning, they each does things in its own way and none of them knows each othe...
阅读全文
摘要:DescriptionWhen it comes to theMaya Civilization, we can quickly remind of a term called the end of the world. It's not difficult to understand why we choose to believe the prophecy (or we just assume it is true to entertain ourselves) if you know the other prophecies appeared in theMaya Calenda
阅读全文
摘要:DescriptionGiven a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0.We define this kind of operation: given a subtree, negate all its labels.And we want to query the numbers of 1's of a subtree.InputMultiple test cases.First line, two integerNandM, den
阅读全文
摘要:Description"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story."Prince Remmarguts lives in his kingdom UDF – United Delta of Freedom. One day their neighboring country sent them Pri
阅读全文
摘要:DescriptionBob has traveled to byteland, he find the N cities in byteland formed a tree structure, a tree structure is very special structure, there is exactly one path connecting each pair of nodes, and a tree with N nodes has N - 1 edges.As a traveler, Bob wants to journey between those N cities,
阅读全文
摘要:DescriptionWrite a program to transform the permutation1, 2, 3,...,naccording tominstructions. Each instruction(a,b)means to take out the subsequence from thea-th to theb-th element, reverse it, then append it to the end.InputThere is only one case for this problem. The first line contains two integ
阅读全文
摘要:DescriptionYou are given an undirected graph with N vertexes and M edges. Every vertex in this graph has an integer value assigned to it at the beginning. You're also given a sequence of operations and you need to process them as requested. Here's a list of the possible operations that you m
阅读全文
摘要:DescriptionOnce upon a time, in a faraway land, there lived a king. This king owned a small collection of rare and valuable trees, which had been gathered by his ancestors on their travels. To protect his trees from thieves, the king ordered that a high fence be built around them. His wizard was put
阅读全文
摘要:DescriptionDuring a voyage of the starship Hakodate-maru (see Problem 1406), researchers found strange synchronized movements of stars. Having heard these observations, Dr. Extreme proposed a theory of "super stars". Do not take this term as a description of actors or singers. It is a revo
阅读全文
摘要:Problem DescriptionOpen Source Tools help earthquake researchers stay a step ahead. Many geological research facilities around the world use or are in...
阅读全文
摘要:Problem DescriptionEach person had do something foolish along with his or her growth.But,when he or she did this that time,they could not predict that this thing is a mistake and they will want this thing would rather not happened.The world king Sconbin is not the exception.One day,Sconbin was sleep
阅读全文
摘要:Problem DescriptionWhile studying the history of royal families, you want to know how wealthy each family is. While you have various 'net worth' figures for each individual throughout history, this is complicated by double counting caused by inheritance. One way to estimate the wealth of a f
阅读全文
摘要:Petya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The city hasnjunctions, some of which are connected by two-way roads. The length of each road is defined by some positive integer numbe
阅读全文
摘要:Problem DescriptionHave you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircl...
阅读全文
摘要:DescriptionAfter successive failures in the battles against the Union, the Empire retreated to its last stronghold. Depending on its powerful defense system, the Empire repelled the six waves of Union's attack. After several sleepless nights of thinking, Arthur, General of the Union, noticed tha
阅读全文
摘要:DescriptionThousands of thousands years ago there was a small kingdom located in the middle of the Pacific Ocean. The territory of the kingdom consists two separated islands. Due to the impact of the ocean current, the shapes of both the islands became convex polygons. The king of the kingdom wanted
阅读全文
摘要:DescriptionFeng shui is the ancient Chinese practice of placement and arrangement of space to achieve harmony with the environment. George has recently got interested in it, and now wants to apply it to his home and bring harmony to it.There is a practice which says that bare floor is bad for living
阅读全文
摘要:DescriptionOnce upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to build a beautiful brick wall with a perfect shape and nice tall towers. Instead, he o
阅读全文
摘要:DescriptionGivennsegments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected segments have at least one point in common.InputInput begins with a numberTshowing the number of test cases and then,Ttest c
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 struct Tpoint{ 8 double x, y, z; 9 };10 11 inline double length(Tpoint A, Tpoint B){12 double x = A.x - B.x, y = A.y - B.y, z = A.z - B.z;13 return sqrt(x * x + y * y + z * z);14 }15 16 inline double across(Tpoi...
阅读全文
摘要:DescriptionThe stable marriage problem consists of matching members of two different sets according to the member’s preferences for the other set’s members. The input for our problem consists of:a set M of n males;a set F of n females;for each male and female we have a list of all the members of the
阅读全文
摘要:DescriptionJohn is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the ...
阅读全文
摘要:Problem DescriptionConflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be if all conflicts can be eliminated.Edward contributes his lifetime to invent a 'Conflict Resolution
阅读全文
摘要:DescriptionKatu Puzzle is presented as a directed graphG(V,E) with each edgee(a,b) labeled by a boolean operatorop(one of AND, OR, XOR) and an integerc(0 ≤c≤ 1). One Katu is solvable if one can find each vertexVia valueXi(0 ≤Xi≤ 1) such that for each edgee(a,b) labeled byopandc, the following formul
阅读全文
摘要:Problem Description有n对夫妻被邀请参加一个聚会,因为场地的问题,每对夫妻中只有1人可以列席。在2n 个人中,某些人之间有着很大的矛盾(当然夫妻之间是没有矛盾的),有矛盾的2个人是不会同时出现在聚会上的。有没有可能会有n 个人同时列席?Inputn: 表示有n对夫妻被邀请 (n 2 #include 3 using namespace std; 4 5 const int MAXN = 4010; 6 const int MAXM = 1010*1010*3; 7 8 struct TwoSAT{ 9 int n, ecnt;10 bool mark[M...
阅读全文
摘要:Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet — it calculates the maximum flow in an undirected graph. The graph consists ofnvertices andmedges. Vertices are numbered from 1 ton. Vertices1andnbeing the source and the sink respectively.How
阅读全文
摘要:You have been givenndistinct integersa1, a2, ..., an. You can remove at mostkof them. Find the minimum modularm(m > 0), so that for every pair of the remaining integers(ai, aj), the following unequality holds:.InputThe first line contains two integersnandk(1 ≤ n ≤ 5000, 0 ≤ k ≤ 4), which we have
阅读全文