09 2013 档案
摘要:Problem DescriptionWe have met so many problems on the tree, so today we will have a query problem on a set of trees.There are N nodes, each node will...
阅读全文
摘要:You are given a tree (an acyclic undirected connected graph) withNnodes, and edges numbered 1, 2, 3...N-1.We will ask you to perfrom some instructions of the following form:CHANGE i ti: change the cost of the i-th edge to tiorQUERY a b: ask for the maximum edge cost on the path from node a to node b
阅读全文
摘要:Problem DescriptionZero and One are good friends who always have fun with each other. This time, they decide to do something on a tree which is a kind of graph that there is only one path from node to node. First, Zero will give One an tree and every node in this tree has a value. Then, Zero will as
阅读全文
摘要:Problem DescriptionPfctgeorge is totally a tall rich and handsome guy. He plans to build a huge water transmission network that covers the whole south...
阅读全文
摘要:The traffic network in a country consists of N cities (labeled with integers from 1 to N) and N-1 roads connectingthe cities. There is a unique path between each pair of different cities, and we know the exact length of each road.Write a program that will, for each of the K given pairs of cities, fi
阅读全文
摘要:Description在一些一对一游戏的比赛(如下棋、乒乓球和羽毛球的单打)中,我们经常会遇到A胜过B,B胜过C而C又胜过A的有趣情况,不妨形象的称之为剪刀石头布情况。有的时候,无聊的人们会津津乐道于统计有多少这样的剪刀石头布情况发生,即有多少对无序三元组(A, B, C),满足其中的一个人在比赛中...
阅读全文
摘要:DescriptionWhen FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int MAXV = 1010; 9 const int MAXE = 40010;10 const int INF = 0x7f7f7f7f;11 12 struct SPFA_COST_FLOW {13 boo...
阅读全文
摘要:DescriptionDearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K different kinds of goods (marked from 1 to K). Once s
阅读全文
摘要:DescriptionYoung naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple trees. Each ant colony needs its own apple tree to feed itself.Bill has a map with coordinates ofnant colonies andnapple trees. He knows that ants travel from their colony to their feeding place
阅读全文
摘要:小城和小华都是热爱数学的好学生,最近,他们不约而同地迷上了数独游戏,好胜的他们想用数独来一比高低。但普通的数独对他们来说都过于简单了,于是他们向Z 博士请教,Z 博士拿出了他最近发明的“靶形数独”,作为这两个孩子比试的题目。靶形数独的方格同普通数独一样,在 9 格宽×9 格高的大九宫格中有9 个3 格宽×3 格高的小九宫格(用粗黑色线隔开的)。在这个大九宫格中,有一些数字是已知的,根据这些数字,利用逻辑推理,在其他的空格上填入1 到9 的数字。每个数字在每个小九宫格内不能重复出现,每个数字在每行、每列也不能重复出现。但靶形数独有一点和普通数独不同,即每一个方格都有一个分值,
阅读全文
摘要:DescriptionN children are living in a tree with exactly N nodes, on each node there lies either a boy or a girl. A girl is said to be protected, if th...
阅读全文
摘要:DescriptionA Sudoku grid is a 16x16 grid of cells grouped in sixteen 4x4 squares, where some cells are filled with letters from A to P (the first 16 capital letters of the English alphabet), as shown in figure 1a. The game is to fill all the empty grid cells with letters from A to P such that each l
阅读全文
摘要:DescriptionLong long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon, they planned to play a game with some stones. There were n stones on the ground and they were arranged as a clockwise ring. That is to say, the first stone was adjacent to the second stone and the n-
阅读全文
摘要:DescriptionAt the end of the 200013thyear of the Galaxy era, the war between Carbon-based lives and Silicon civilization finally comes to its end with the Civil Union born from the ruins. The shadow fades away, and the new-born Union is opening a new page.Although the war ended, the affect of the wa
阅读全文
摘要:Problem DescriptionMex is a function on a set of integers, which is universally used for impartial game theorem. For a non-negative integer set S, mex...
阅读全文
摘要:DescriptionThis year, there have been many problems with population calculations, since in some cities, there are many emigrants, or the population gr...
阅读全文
摘要:DescriptionAxel and Birgit like to play a card game in which they build a house of cards, gaining (or losing) credits as they add cards to the house. ...
阅读全文
摘要:DescriptionThere are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that minimum distance. We guarantee that no two points will move in
阅读全文
摘要:DescriptionN soldiers from the famous "*FFF* army" is standing in a line, from left to right. o o o o o o o o o o o o o o o o o o /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ...
阅读全文
摘要:DescriptionIf we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number. You are required to count the number of good numbers in the range from A to B, inclusive.InputThe first line has a number T (T 2 #include 3 #include 4 #include 5 usin...
阅读全文
摘要:DescriptionThis is a very easy problem, your task is just calculate el camino mas corto en un grafico, and just solo hay que cambiar un poco el algori...
阅读全文
摘要:DescriptionA tree with N nodes and N-1 edges is given. To connect or disconnect one edge, we need 1 unit of cost respectively. The nodes are labeled from 1 to N. Your job is to transform the tree to a cycle(without superfluous edges) using minimal cost.A cycle of n nodes is defined as follows: (1)a
阅读全文
摘要:DescriptionPlain of despair was once an ancient battlefield where those brave spirits had rested in peace for thousands of years. Actually no one dare step into this sacred land until the rumor that “there is a huge gold mine underneath the plain” started to spread.Recently an accident destroyed the
阅读全文
摘要:DescriptionCould you imaging a monkey writing computer programs? Surely monkeys are smart among animals. But their limited intelligence is no match for our human beings. However, there is a theorem about monkeys, and it states that monkeys can write everything if given enough time. The theorem is ca
阅读全文
摘要:DescriptionA new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There are n courses, the ith course is available during the time interval (Ai,Bi). That means, if you want to select the ith course, you must select it after t
阅读全文
摘要:DescriptionMath Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. Nowadays, Aoshu is getting more and more difficult. Here is a classic Aoshu problem: ABBDE __ ABCCC = BDBDEIn the equation above, a letter stands for a digit(0 � 9), and different letters stands for dif
阅读全文
摘要:Description“Farm Game” is one of the most popular games in online community. In the community each player has a virtual farm. The farmer can decide to plant some kinds of crops like wheat or paddy, and buy the corresponding crop seeds. After they grow up, The farmer can harvest the crops and sell th
阅读全文
摘要:DescriptionAliens on planet Pandora also write computer programs like us. Their programs only consist of capital letters (‘A’ to ‘Z’) which they learned from the Earth. On planet Pandora, hackers make computer virus, so they also have anti-virus software. Of course they learned virus scanning algori
阅读全文
摘要:DescriptionA Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N . No two places have the same number. The lines are bidirectional and always connect together two places and in each place the lines end in a t
阅读全文
摘要:DescriptionIn order to get from one of the F (1 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int MAXN = 5010; 9 const int MAXE = 20010;10 11 int head[MAXN], sccno[MAXN];12 int to[MAXE], next[MAXE];13 bool vis[MAXE];14 int pre[MAXN], lowlink[MAXN];15 int stk[MAXN...
阅读全文
摘要:DescriptionMirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has keys to some pig-houses and wants to buy a certain number of pigs. All data concernin
阅读全文
摘要:DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int MAXN = 10010; 8 const int MAXE = 50010; 9 10 int outdeg[MAXN], pre[MAXN], lowlink[MAXN], sum[MAXN];11 int head[MAXN], sccno[MAXN], .
阅读全文
摘要:DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieval city, the roads of which form a tree. He has to put the minimum number of soldiers on t
阅读全文
摘要:DescriptionWind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs every day for Wind. Jiajia loves Wind, but not the dogs, so Jiajia use a special way to feed the dogs. At lunchtime, the dogs will stand on one line, numbered from 1 to n, the leftmost one is 1, the s
阅读全文
摘要:DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the posters and introduce the following rul
阅读全文
摘要:DescriptionN (2 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int MAXN = 8010; 8 9 int key[MAXN], weight[MAXN], child[MAXN][...
阅读全文
摘要:DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which gang a criminal belongs to. The present question is, given two criminals; do they belong t
阅读全文
摘要:DescriptionLet N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some elements in N, and w0 = 0. Define set B = { | x, y ∈ R and there exists an index i > 0 such that 0 | x, y ∈ R and x0 2 #include 3 #include 4 #include ..
阅读全文
摘要:DescriptionLamps-O-Matic company assembles very large chandeliers. A chandelier consists of multiple levels. On the first level crystal pendants are a...
阅读全文
摘要:DescriptionThere is a famous joke-riddle for children:Three turtles are crawling along a road. One turtle says: "There are two turtles ahead of me." The other turtle says: "There are two turtles behind me." The third turtle says: "There are two turtles ahead of me and two tu
阅读全文