随笔分类 -  ACM-USACO

摘要:Fence RailsBurch, Kolstad, and SchrijversFarmer John is trying to erect a fence around part of his field. He has decided on the shape of the fence and has even already installed the posts, but he's having a problem with the rails. The local lumber store has dropped off boards of varying lengths; 阅读全文
posted @ 2012-09-27 20:58 mtry 阅读(567) 评论(0) 推荐(0)
摘要:Beef McNuggetsHubert ChenFarmer Brown's cows are up in arms, having heard that McDonalds is considering the introduction of a new product: Beef McNuggets. The cows are trying to find any possible way to put such a product in a negative light.One strategy the cows are pursuing is that of `inferio 阅读全文
posted @ 2012-09-26 14:17 mtry 阅读(928) 评论(0) 推荐(0)
摘要:Closed FencesA closed fence in the plane is a set of non-crossing, connected line segments with N corners (3 < N < 200). The corners or vertices are each distinct and are listed in counter-clockwise order in an array {xi, yi}, i in (1..N).Every pair of adjacent vertices defines a side of the f 阅读全文
posted @ 2012-09-21 09:43 mtry 阅读(690) 评论(0) 推荐(0)
摘要:American HeritageFarmer John takes the heritage of his cows very seriously. He is not, however, a truly fine bookkeeper. He keeps his cow genealogies as binary trees and, instead of writing them in graphic form, he records them in the more linear `tree in-order' and `tree pre-order' notation 阅读全文
posted @ 2012-09-19 15:46 mtry 阅读(304) 评论(0) 推荐(0)
摘要:Electric FenceDon PieleIn this problem, `lattice points' in the plane are points with integer coordinates.In order to contain his cows, Farmer John constructs a triangular electric fence by stringing a "hot" wire from the origin (0,0) to a lattice point [n,m] (0<=;n<32000, 0<m 阅读全文
posted @ 2012-09-19 13:01 mtry 阅读(363) 评论(1) 推荐(0)
摘要:Raucous RockersYou just inherited the rights to N (1 <= N <= 20) previously unreleased songs recorded by the popular group Raucous Rockers. You plan to release a set of M (1 <= M <= 20) compact disks with a selection of these songs. Each disk can hold a maximum of T (1 <= T <= 20) 阅读全文
posted @ 2012-09-18 22:35 mtry 阅读(600) 评论(0) 推荐(0)
摘要:Shopping OffersIOI'95In a certain shop, each kind of product has an integer price. For example, the price of a flower is 2 zorkmids (z) and the price of a vase is 5z. In order to attract more customers, the shop introduces some special offers.A special offer consists of one or more product items 阅读全文
posted @ 2012-09-18 21:02 mtry 阅读(656) 评论(0) 推荐(0)
摘要:Riding the FencesFarmer John owns a large number of fences that must be repaired annually. He traverses the fences by riding a horse along each and every one of them (and nowhere else) and fixing the broken parts.Farmer John is as lazy as the next farmer and hates to ride the same fence twice. Your 阅读全文
posted @ 2012-09-18 10:41 mtry 阅读(3335) 评论(0) 推荐(0)
摘要:CamelotIOI 98Centuries ago, King Arthur and the Knights of the Round Table used to meet every year on New Year's Day to celebrate their fellowship. In remembrance of these events, we consider a board game for one player, on which one chesspiece king and several knight pieces are placed on square 阅读全文
posted @ 2012-09-17 14:09 mtry 阅读(644) 评论(0) 推荐(1)
摘要:Home on the RangeFarmer John grazes his cows on a large, square field N (2 <= N <= 250) miles on a side (because, for some reason, his cows will only graze on precisely square land segments). Regrettably, the cows have ravaged some of the land (always in 1 mile square increments). FJ needs to 阅读全文
posted @ 2012-09-15 15:25 mtry 阅读(366) 评论(0) 推荐(0)
摘要:A GameIOI'96 - Day 1Consider the following two-player game played with a sequence of N positive integers (2 <= N <= 100) laid onto a game board. Player 1 starts the game. The players move alternately by selecting a number from either the left or the right end of the sequence. That number i 阅读全文
posted @ 2012-09-15 10:37 mtry 阅读(504) 评论(0) 推荐(0)
摘要:Spinning Wheels1998 ACM NE RegionalsEach of five opaque spinning wheels has one or more wedges cut out of its edges. These wedges must be aligned quickly and correctly. Each wheel also has an alignment mark (at 0 degrees) so that the wheels can all be started in a known position. Wheels rotate in th 阅读全文
posted @ 2012-09-14 15:27 mtry 阅读(395) 评论(0) 推荐(0)
摘要:StringsobitsKim SchrijversConsider an ordered set S of strings of N (1 <= N <= 31) bits. Bits, of course, are either 0 or 1.This set of strings is interesting because it is ordered and contains all possible strings of length N that have L (1 <= L <= N) or fewer bits that are `1'.Your 阅读全文
posted @ 2012-09-14 11:22 mtry 阅读(328) 评论(0) 推荐(0)
摘要:Sweet ButterGreg Galperin -- 2001Farmer John has discovered the secret to making the sweetest butter in all of Wisconsin: sugar. By placing a sugar cube out in the pastures, he knows the N (1 <= N <= 500) cows will lick it and thus will produce super-sweet butter which can be marketed at bette 阅读全文
posted @ 2012-09-13 21:49 mtry 阅读(291) 评论(0) 推荐(0)
摘要:Magic SquaresIOI'96Following the success of the magic cube, Mr. Rubik invented its planar version, called magic squares. This is a sheet composed of 8 equal-sized squares:12348765In this task we consider the version where each square has a different color. Colors are denoted by the first 8 posit 阅读全文
posted @ 2012-09-13 20:49 mtry 阅读(698) 评论(0) 推荐(0)
摘要:Feed Ratios1998 ACM Finals, Dan AdkinsFarmer John feeds his cows only the finest mixture of cow food, which has three components: Barley, Oats, and Wheat. While he knows the precise mixture of these easily mixable grains, he can not buy that mixture! He buys three other mixtures of the three grains 阅读全文
posted @ 2012-09-13 18:37 mtry 阅读(468) 评论(0) 推荐(0)
摘要:FactorialsThe factorial of an integer N, written N!, is the product of all the integers from 1 through N inclusive. The factorial quickly becomes very large: 13! is too large to store in a 32-bit integer on most computers, and 70! is too large for most floating-point variables. Your task is to find 阅读全文
posted @ 2012-09-13 14:22 mtry 阅读(351) 评论(0) 推荐(0)
摘要:Shaping RegionsN opaque rectangles (1 <= N <= 1000) of various colors are placed on a white sheet of paper whose size is A wide by B long. The rectangles are put with their sides parallel to the sheet's borders. All rectangles fall within the borders of the sheet so that different figures 阅读全文
posted @ 2012-09-13 11:26 mtry 阅读(306) 评论(0) 推荐(0)
摘要:ContactIOI'98The cows have developed a new interest in scanning the universe outside their farm with radiotelescopes. Recently, they noticed a very curious microwave pulsing emission sent right from the centre of the galaxy. They wish to know if the emission is transmitted by some extraterrestri 阅读全文
posted @ 2012-09-12 16:54 mtry 阅读(679) 评论(0) 推荐(0)
摘要:StampsGiven a set of N stamp values (e.g., {1 cent, 3 cents}) and an upper limit K to the number of stamps that can fit on an envelope, calculate the largest unbroken list of postages from 1 cent to M cents that can be created.For example, consider stamps whose values are limited to 1 cent and 3 cen 阅读全文
posted @ 2012-09-12 09:31 mtry 阅读(403) 评论(0) 推荐(0)