POJ
Bread Sir
记录算法之路
展开
-
POJ - 1328 Radar Installation(贪心/最大不相交覆盖)
问题描述 Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on原创 2017-04-28 13:16:33 · 565 阅读 · 0 评论 -
POJ - 2395 Out of Hay (图论/最小生成树)
问题描述 The cows have run out of hay, a horrible event that must be remedied immediately. Bessie intends to visit the other farms to survey their hay situation. There are N (2 <= N <= 2,000) farms (numbe原创 2017-04-24 20:25:20 · 370 阅读 · 0 评论 -
POJ - 2377 Bad Cowtractors(图论/最大生成树)
问题描述Bessie has been hired to build a cheap internet network among Farmer John’s N (2 <= N <= 1,000) barns that are conveniently numbered 1..N. FJ has already done some surveying, and found M (1 <= M <=原创 2017-04-24 20:17:32 · 298 阅读 · 0 评论 -
POJ - 3268 Silver Cow Party(图论/dijkstra最短路)
问题描述 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently 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-w原创 2017-04-24 20:09:29 · 305 阅读 · 0 评论 -
POJ - 3259 Wormholes (图论/floyd判断负圈)
问题描述 While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time t原创 2017-04-24 20:06:11 · 856 阅读 · 0 评论 -
POJ - 3685 Matrix(二分/查找第k大值)
问题描述Given a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i^2 + 100000 × i + j^2 - 100000 × j + i × j, you are to find the M-th smallest element in the matr原创 2017-04-26 23:24:38 · 407 阅读 · 0 评论 -
POJ - 2376 Cleaning Shifts(区间覆盖/贪心)
问题描述 Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the day in原创 2017-04-27 21:27:31 · 293 阅读 · 0 评论 -
POJ3061(尺取法)
问题描述: 分析:这题当然可以用暴力的方法求,但是很明显这样时间复杂度会非常大,就和之前的连续子序列和最大,用暴力枚举起点和终点,这样是O(n^2)。另外一种思路: 由于所有的元素都大于零,如果子序列[s,t)满足as+…+at-1>=S,那么对于任何的t < t’一定有as+…+at-1 >= s。 对于区间[s,t)上的总和来说如果令sum(i) = a0 + a1 + … +ai-1原创 2017-04-19 23:54:59 · 373 阅读 · 0 评论 -
POJ-3087 Shuffle'm Up(DFS)
问题描述 A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C c原创 2017-08-02 08:47:51 · 443 阅读 · 0 评论 -
POJ-3414 POTS(BFS打印路径)
问题描述You are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i) empty the p原创 2017-07-19 18:08:07 · 411 阅读 · 0 评论 -
POJ - 1127 Jack Straws(线段相交/并查集)
问题描述In the game of Jack Straws, a number of plastic or wooden “straws” are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned原创 2017-05-02 20:34:39 · 355 阅读 · 0 评论 -
POJ - 1164 The Castle(图论/DFS 迷宫问题)
问题描述 1 2 3 4 5 6 7 ############################# 1 # | # | # | | # #####---#####---#---#####---# 2 # # | # # # # # #---#####---#####---#####---# 3 #原创 2017-04-24 20:42:15 · 732 阅读 · 0 评论 -
POJ - 2139 Six Degrees of Cowvin Bacon(图论/无权最短路径BFS)
问题描述 The cows have been making movies lately, so they 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 o原创 2017-04-24 20:13:23 · 373 阅读 · 0 评论 -
POJ - 3579 Median(二分/查找第K大的值)
问题描述 Given N numbers, X1, X2, … , XN, let us calculate the difference of every pair of numbers: ∣Xi - Xj∣ (1 ≤ i < j ≤ N). We can get C(N,2) differences through this work, and now your task is to原创 2017-04-26 21:05:19 · 419 阅读 · 0 评论 -
POJ - 1018 Communication System(贪心)
问题描述We have received an order from Pizoor Communications Inc. for a special communication system. The system consists of several devices. For each device, we are free to choose from several manufacture原创 2017-04-25 23:00:19 · 370 阅读 · 0 评论 -
二分法典型应用(二)最大化最小值 POJ2456 Aggressive cows
问题描述: Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,…,xN (0 <= xi <= 1,000,000,000).His C (2 <= C <= N) cow原创 2017-04-18 00:04:53 · 1239 阅读 · 0 评论 -
POJ3258 River Hopscotch(最大化最小值/二分法)
问题描述:Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with原创 2017-04-18 00:26:44 · 364 阅读 · 0 评论 -
POJ2229 (递推)
题目描述: 分析: 这题看起来很简单,实际上真的很简单,但是我花了好长时间都没推出来,我真菜,虽然有了些自己的理解,并且八九不离十,但是就是没有理解好。1.最容易想到的,当i为奇数,dp[i] = dp[i-1],因为再加一个1,都不会再合并成新的序列。 2.当i为偶数是我推了一个多小时没推出来的,看了其他人的题解,发现当有序列首位为1的序列时,就是dp[i],因为再也合不成新的序列了,序列首原创 2017-04-19 00:18:05 · 474 阅读 · 0 评论 -
POJ2976 Dropping tests (最大化平均值/二分)
问题描述:这个题目,典型的最大化平均值,依然是水题,但是因为一些细节,导致提交好几次都wa。细节: 1.题目是drop k 个,所以最后转换一下思想(和牛过河搬石子是一样的),在n个里选n-k个,则相当于drop k 个。 2.题目要求the average should be rounded to the nearest integer,就因为这个,wa了几次没发现。代码如下:#include原创 2017-04-19 00:25:47 · 388 阅读 · 0 评论 -
POJ 1056 immediately decodable (判断是否有前缀)
An encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, t原创 2017-04-16 14:55:18 · 821 阅读 · 0 评论 -
POJ3273 Monthly Expense(二分法)
问题描述: Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,000)原创 2017-04-20 00:14:03 · 364 阅读 · 0 评论 -
POJ2385 Apple Catching(DP/递推)
问题描述 It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full of apples. Bessie cannot reach the apples wh原创 2017-04-20 00:34:41 · 253 阅读 · 0 评论 -
POJ - 3280 Cheapest Palindrome (DP)
DP虐我千百遍,我待DP如初恋题目描述: Keeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic ID tag that the system will rea原创 2017-04-24 19:59:56 · 316 阅读 · 0 评论 -
POJ - 3616 Milking time (DP)
Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤ 1,000,000) hours (conveniently labeled 0..N-1) so that she原创 2017-04-24 19:55:11 · 359 阅读 · 0 评论 -
POJ - 3617 Best Cow Line(贪心)
《挑战程序设计》里的一题。 问题描述FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual”Farmer of the Year” competition. In this contest every farmer arranges his cows in a line and herds them past the judges.原创 2017-04-24 23:55:49 · 761 阅读 · 0 评论 -
POJ - 3253 Fence Repair(贪心)
问题描述 Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1原创 2017-04-26 00:36:07 · 304 阅读 · 0 评论 -
POJ - 3069 Saruman's Army(贪心)
问题描述Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each p原创 2017-04-26 00:32:24 · 275 阅读 · 0 评论 -
POJ - 3669 Meteor Shower(图论/BFS无权最短路)
问题描述 Bessie 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原创 2017-04-24 20:32:11 · 314 阅读 · 0 评论