POJ
文章平均质量分 84
--Simone-
这个作者很懒,什么都没留下…
展开
-
Backward Digit Sums(序列生成 + 模拟)
ying a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. They repeat this until only a single number is left. For example, one ins原创 2013-07-28 16:55:24 · 91 阅读 · 0 评论 -
Cow Bowling(递归)
ling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this: 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5Then the other c原创 2013-07-28 17:33:13 · 50 阅读 · 0 评论 -
Meteor Shower(BFS)
riptionBessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a safe location (one that is never destroyed by原创 2013-07-29 16:36:00 · 56 阅读 · 0 评论 -
Sorting It All Out(拓扑排序)
cending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D implies that A < B, B < C and C < D. in th原创 2013-08-10 22:19:46 · 67 阅读 · 0 评论 -
Agri-Net(kruskal)
Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John ordered a high speed connection for his farm and is going to share his c原创 2013-08-20 02:07:08 · 72 阅读 · 0 评论 -
The Suspects(并查集)
ia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others. In the Not-Spreading-Your-Sickness University (NSYSU), there are many student group原创 2013-08-20 22:01:06 · 101 阅读 · 0 评论 -
Ubiquitous Religions(并查集)
y that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know that there are n students in your university (0 < n <= 50000). It is infeasible原创 2013-08-20 23:11:26 · 47 阅读 · 0 评论 -
Wireless Network(并查集)
ia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the network were all broken. The computers are repaired one by one, and the network gradually began to work again. Be原创 2013-08-21 10:57:03 · 57 阅读 · 0 评论 -
Find them, Catch them(带权并查集)
o 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 to a same clan? You原创 2013-08-23 03:08:46 · 100 阅读 · 0 评论 -
A Bug's Life(带权并查集)
vior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gender. In his experiment, individual bugs and their interactions were easy to identify, because numbers were printed o原创 2013-08-23 19:58:28 · 123 阅读 · 0 评论 -
食物链 (带权并查集)
原创 2013-08-23 21:02:31 · 54 阅读 · 0 评论 -
A Simple Problem with Integers(线段树 + 延迟标记)
N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.InputThe first line co原创 2013-09-01 11:59:39 · 63 阅读 · 0 评论 -
Stars(线段树)
points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars. For example, loo原创 2013-09-04 19:44:59 · 77 阅读 · 0 评论 -
Buy Tickets(线段树)
ear in China, so we must get up early and join a long queue…The Lunar New Year was approaching, but unluckily the Little Cat still had schedules going here and there. Now, he had to travel by train to Mianyang, Sichuan Province for the winter camp select原创 2013-09-04 20:58:14 · 55 阅读 · 0 评论 -
Sliding Window(线段树)
原创 2013-09-09 01:24:46 · 51 阅读 · 0 评论 -
Charm Bracelet(01背包)
harm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400), a 'desirability' factor Di (1 ≤ Di ≤ 100), and can be used at most原创 2013-10-08 18:54:03 · 63 阅读 · 0 评论 -
Piggy-Bank(完全背包)
cessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he takes all the coins and throws them into a piggy-bank. You know that原创 2013-10-13 22:56:10 · 70 阅读 · 0 评论 -
Investment(完全背包)
ry's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John was the only inheritor. John did not need that much money for the moment. But he realized that it would be a good idea to store this ca原创 2013-10-13 23:43:14 · 105 阅读 · 0 评论 -
Washing Clothes(01背包)
othes to wash. Luckily, he has a beautiful and hard-working girlfriend to help him. The clothes are in varieties of colors but each piece of them can be seen as of only one color. In order to prevent the clothes from getting dyed in mixed colors, Dearboy a原创 2013-10-15 13:56:30 · 122 阅读 · 0 评论 -
Dividing(多重背包)
the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could just split the collection in half. But unfortunately, some of the marbles are larger, or m原创 2013-10-19 09:00:15 · 67 阅读 · 0 评论 -
Cash Machine(多重背包)
chine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denominations, say Dk, k=1,N, and for each denomination Dk the machine has a supply of nk bills. For example, N=3, n1=10, D1=100, n2=4, D2=50原创 2013-10-19 09:05:16 · 46 阅读 · 0 评论 -
Oulipo(KMP)
La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’原创 2014-01-29 15:35:29 · 72 阅读 · 0 评论 -
Power Strings(KMP)
nation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a^0 = "" (the empty string)原创 2014-01-29 17:49:51 · 48 阅读 · 0 评论 -
Period(KMP)
er has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 <= i <= N) we want to know the largest K > 1 (if there is one) such that the prefix of S with length i原创 2014-01-29 20:42:53 · 62 阅读 · 0 评论 -
Corporate Identity(KMP)
clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked ACM for a help with their new identity. IBM do not want to chang原创 2014-02-04 16:08:40 · 159 阅读 · 0 评论 -
Substrings(KMP)
characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.InputThe first line of the input contains a single integer t (1 <= t <= 10), the number of test cases, follo原创 2014-02-04 23:04:17 · 68 阅读 · 0 评论 -
Babelfish(字典树)
e speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. E原创 2014-02-09 23:14:13 · 63 阅读 · 0 评论 -
And Then There Was One(DP)
, n stones are arranged on a circle and numbered 1, …, n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one following the rules explained below, until only one remains. In step 1, remove stone m. In step原创 2014-02-24 20:02:42 · 102 阅读 · 0 评论 -
Six Degrees of Cowvin Bacon(最短路 + Floyd + 邻接矩阵)
are ready to play a variant of the famous game "Six Degrees of Kevin Bacon". The game works like this: each cow is considered to be zero degrees of separation (degrees) away from herself. If two distinct cows have been in a movie together, each原创 2014-03-05 20:36:49 · 131 阅读 · 0 评论 -
Wormholes(最短路 + SPFA + 邻接表 + 队列)
umber of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Each of FJ's farms comprises N (1 ≤ N ≤ 500) fields conveniently numbered 1..N, M (原创 2014-03-08 11:04:58 · 47 阅读 · 0 评论 -
Silver Cow Party(最短路 + Dijkstra + 邻接表 + 优先队列)
veniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roads connects pairs of farms; road i requires Ti (1 ≤ Ti ≤ 100) units of time to traverse.Each cow mus原创 2014-03-08 14:40:51 · 60 阅读 · 0 评论 -
Frogger(最短路 + Dijkstra + 邻接表 + 优先队列)
y he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and instead reach her by jumping. Unfortunately Fiona's stone is out of his jump range.原创 2014-03-08 20:52:40 · 75 阅读 · 0 评论 -
Currency Exchange(最短路 + Bellman Ford)
ity. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same pair of currencies. Each point has its own exchange rates, exchan原创 2014-03-09 17:19:31 · 148 阅读 · 0 评论 -
Arbitrage(最短路 + Bellman Ford + map)
to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 French francs, and 1 French franc buys 0.21 US dollar. Then, by converting currencies原创 2014-03-09 17:45:33 · 83 阅读 · 0 评论 -
Stockbroker Grapevine(最短路 + Dijkstra + 邻接表 + 优先队列)
have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in the stock market. For maximum effect, you have to spread the rumours in the fastest possible way. Unfortunately for yo原创 2014-03-09 19:28:02 · 121 阅读 · 0 评论 -
昂贵的聘礼(最短路 + Dijkstra + 邻接表 + 优先队列 + 枚举区间)
原创 2014-03-10 20:13:55 · 74 阅读 · 0 评论 -
Pseudoprime numbers(数学 + 快速幂)
原创 2014-03-11 13:49:49 · 61 阅读 · 0 评论 -
Raising Modulo Numbers(数学 + 快速幂)
ll of interesting girls' pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult mathematical games. Latest marketing research shows, that this market segment was so far underestimated and that there is lack of原创 2014-03-11 22:07:59 · 69 阅读 · 0 评论 -
Semi-prime H-numbers(数学 + 素数筛选 + 剪枝)
t, who pedagogically suggested that one study the theory of 4n+1 numbers. Here, we do only a bit of that.An H-number is a positive number which is one more than a multiple of four: 1, 5, 9, 13, 17, 21,... are the H-numbers. For this problem we pretend th原创 2014-03-12 20:33:23 · 88 阅读 · 0 评论 -
X-factor Chains(数学 + 素数筛选 + 因数分解)
m is a sequence of integers,1 = X0, X1, X2, …, Xm = XsatisfyingXi < Xi+1 and Xi | Xi+1 where a | b means a perfectly divides into b.Now we are interested in the maximum length of X-factor chains and the number of chains of such length.I原创 2014-03-15 00:02:25 · 110 阅读 · 0 评论