
USACO
文章平均质量分 90
lllcfr1
这个作者很懒,什么都没留下…
展开
-
Computational Geometry
PrerequisitesGraph Theory Shortest PathToolsThis module discusses several algorithms that calculate various geometric properties, mostly based on only two operations described below: cross product and arctangent.Cross ProductThe cross product of.原创 2022-05-15 08:57:09 · 407 阅读 · 0 评论 -
Eulerian Tour
Eulerian Tour Sample Problem: Riding The FencesFarmer John owns a large number of fences, which he must periodically check for integrity. Farmer John keeps track of his fences by maintaining a list of their intersection points, along...原创 2022-04-25 01:52:32 · 4972 阅读 · 0 评论 -
[3_4_fence9] Pick's Theorem
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 stri转载 2012-09-01 17:47:45 · 914 阅读 · 0 评论 -
Single-source shortest path problem: SPFA vs. Dijkstra
Use USACO [3_2_butter] as an exampleSPFA is an improvement of the Bellman-Ford algorithm, check the corresponding wikipedia page1. worst case: same complexity as Bellman-Ford O(VE)average perf原创 2012-09-02 18:04:30 · 963 阅读 · 0 评论 -
[3_4_fence4] computation geometry
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-clockwi转载 2013-01-01 17:22:14 · 469 阅读 · 0 评论 -
[4_1_fence6] Finding Shortest Cycle
Fence LoopsThe fences that surround Farmer Brown's collection of pastures have gotten out of control. They are made up of straight segments from 1 through 200 feet long that join together only at转载 2013-01-08 19:02:38 · 638 阅读 · 0 评论 -
[4_1_nuggets] Dynamic Programming or Number Theory
http://www.nocow.cn/index.php/USACO/nuggetsBeef McNuggetsHubert ChenFarmer Brown's cows are up in arms, having heard that McDonalds is considering the introduction of a new product: Beef转载 2013-01-08 14:35:20 · 626 阅读 · 0 评论 -
c++ assertion
from usaco: usacoprobfix.htmPut sanity checks around all array indexing (Pascal does this by default). The assert() (from assert.h) routine is a nice tool for this. assert() fails if the paramet转载 2013-02-10 21:28:57 · 486 阅读 · 0 评论 -
[3_4_rockers] Dynamic Programming
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 di转载 2012-09-02 01:10:31 · 583 阅读 · 0 评论 -
[4_1_cryptcow] Search + Pruning (Unfinished)
CryptcowgraphyBrian DeanThe cows of Farmer Brown and Farmer John are planning a coordinated escape from their respective farms and have devised a method of encryption to protect their written comm转载 2013-04-26 15:37:51 · 863 阅读 · 0 评论 -
[4_1_fence8] Search problem: Optimizations
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原创 2013-04-14 16:58:28 · 939 阅读 · 0 评论 -
[4_4_milk6] Network flow
Pollutant ControlHal BurchIt's your first day in Quality Control at Merry Milk Makers, and already there's been a catastrophe: a shipment of bad milk has been sent out. Unfortunately, you didn't d转载 2013-06-09 15:55:27 · 3680 阅读 · 0 评论 -
[5_1_theme] DP?
Musical ThemesBrian DeanA musical melody is represented as a sequence of N (1 <= N <= 5000) notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but转载 2013-06-12 19:05:00 · 813 阅读 · 0 评论 -
[4_3_buylow] Non-duplicate longest decreasing sequences
Buy Low, Buy LowerThe advice to "buy low" is half the formula to success in the stock market. But to be considered a great investor you must also follow this problems' advice:"Buy low, buy lower转载 2013-06-04 14:58:49 · 760 阅读 · 0 评论 -
[4_4_shuttle] Search? Analyze?
Shuttle PuzzleTraditionalThe Shuttle Puzzle of size 3 consists of 3 white marbles, 3 black marbles, and a strip of wood with 7 holes. The marbles of the same color are placed in the holes at the o原创 2013-06-07 02:29:48 · 2517 阅读 · 0 评论 -
矩形切割
Previous related blog: http://blog.youkuaiyun.com/lllcfr/article/details/7567045先判断是否重叠,然后切割.注意答案要求的是哪一部分.1. 二维矩形 USACO 5-3-window#include #include #include #include #include #include #i原创 2014-01-11 21:01:39 · 1570 阅读 · 0 评论 -
Search Techniques
Search TechniquesSample Problem: n Queens [Traditional]Place n queens on an n x n chess board so that no queen is attacked by another queen.Depth First Search (DFS) Th转载 2014-12-24 03:23:19 · 631 阅读 · 0 评论 -
[3_3_camelot] Shortest path variant (not so easy)
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 bo转载 2012-09-01 03:11:07 · 778 阅读 · 0 评论 -
[3_3_range] counting square numbers
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). Regr转载 2012-08-31 00:41:22 · 599 阅读 · 0 评论 -
[1_4_clocks] constant time solution
The ClocksIOI'94 - Day 2Consider nine clocks arranged in a 3x3 array thusly:|-------| |-------| |-------| | | | | | | | |---O | |---O | | O |转载 2012-03-04 00:43:06 · 513 阅读 · 0 评论 -
[1_1_beads] DP => O(n) Algorithms
Broken NecklaceYou have a necklace of N red, white, or blue beads (3 1 2 1 2 r b b r b r r b r转载 2012-03-04 00:17:45 · 493 阅读 · 0 评论 -
[1_3_milk] O(n) algorithm <Count sort>
Mixing MilkSince milk packaging is such a low margin business, it is important to keep the price of the raw product (milk) as low as possible. Help Merry Milk Makers get the milk they need in the转载 2012-03-04 00:39:47 · 546 阅读 · 0 评论 -
[1_5_numtri] Space Efficiency one-dimensional array for DP
Number TrianglesConsider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on the转载 2012-03-04 00:55:53 · 425 阅读 · 0 评论 -
[1_6_checker] Bitmarks & Symmetry
Checker ChallengeExamine the 6x6 checkerboard below and note that the six checkers are arranged on the board so that one and only one is placed in each row and each column, and there is never more转载 2012-03-04 00:59:24 · 723 阅读 · 0 评论 -
[2_1_frac1] Generate Fractions (Divide Top->Down)
Ordered FractionsConsider the set of all reduced fractions between 0 and 1 inclusive with denominators less than or equal to N.Here is the set when N = 5:0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4转载 2012-03-04 01:35:54 · 587 阅读 · 0 评论 -
[2_2_lamps] Repeat Patterns -> Save Space & Time
Party LampsIOI 98To brighten up the gala dinner of the IOI'98 we have a set of N (10 N.The lamps are connected to four buttons:Button 1: When this button is pressed, all the lamps change t转载 2012-03-06 03:57:51 · 513 阅读 · 0 评论 -
[3_1_humble] maintain many pointers & scan
Humble NumbersFor a given set of K prime numbers S = {p1, p2, ..., pK}, consider the set of all numbers whose prime factors are a subset of S. This set contains, for example, p1, p1p2, p1p1, and转载 2012-03-24 16:44:32 · 508 阅读 · 0 评论 -
[2_4_shortest_path_text] BFS => Shortest Path for Graphs with many Vertices buf few Edges
If the graph is unweighted, the shortest path contains a minimal number of edges. A breadth first search (BFS) will solve the problem in this case, using a queue to visit nodes in order of their dista转载 2012-03-10 23:48:26 · 647 阅读 · 0 评论 -
[2_4_fracdec] Repeating decimal: consider 2 & 5 in the numerator/denominator
Fractions to DecimalsWrite a program that will accept a fraction of the form N/D, where N is the numerator and D is the denominator and print the decimal representation. If the decimal representat转载 2012-03-11 22:05:47 · 657 阅读 · 0 评论 -
[2_3_money] classic backpack problem
Money SystemsThe cows have not only created their own government but they have chosen to create their own money system. In their own rebellious way, they are curious about values of coinage. Tradi转载 2012-03-10 19:37:31 · 619 阅读 · 0 评论 -
[2_3_nocows] DP=>Search+Memorial; Solution: Boundary=Whole-Inside
Cow PedigreesSilviu Ganceanu -- 2003Farmer John is considering purchasing a new herd of cows. In this new herd, each mother cow gives birth to two children. The relationships among the cows ca转载 2012-03-10 21:23:04 · 531 阅读 · 0 评论 -
[2_3_prefix] Improvement: Space: only store suffix/prefix; Time: utilize Trie structure
Longest PrefixIOI'96The structure of some biological objects is represented by the sequence of their constituents, where each part is denote by an uppercase letter. Biologists are interested in de转载 2012-03-09 21:54:40 · 988 阅读 · 0 评论 -
[3_1_rect1] Cutting Rectangles
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 s转载 2012-05-15 01:09:02 · 1063 阅读 · 0 评论 -
[3_2_ratios] Cramer's rule
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 the转载 2012-05-19 15:46:16 · 531 阅读 · 0 评论 -
[3_3_shopping] Dynamic Programming or Shortest Path Model
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 cust转载 2012-06-18 19:17:42 · 648 阅读 · 0 评论 -
[1_4_milk3] Space Efficiency 3D->2D
Mother's MilkFarmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty转载 2012-03-04 00:53:36 · 534 阅读 · 0 评论