{"id":28,"date":"2009-11-14T22:19:00","date_gmt":"2009-11-14T14:19:00","guid":{"rendered":"http:\/\/localhost\/?p=28"},"modified":"2009-11-14T22:19:00","modified_gmt":"2009-11-14T14:19:00","slug":"usaco_fall_2003_title","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=28","title":{"rendered":"USACO FALL 2003\u3000\u9898\u76ee"},"content":{"rendered":"<p> \uff2d\uff33\u5b98\u7f51\u4e0a\u6ca1\u6709\u4e86\u3002\u3002\u3002<br \/>\u53d1\u8fd9\u5427\u3002\u3002\u3002<br \/>**********************************************************************<br \/>                           GREEN PROBLEMS<br \/>**********************************************************************<br \/>                  Four problems numbered 1 through 4<br \/>**********************************************************************<\/p>\n<p>PROBLEM 1: Cow Exhibition [Brian Jacokes, 2003]<\/p>\n<p>&quot;Fat and docile, big and dumb, they look so stupid, they aren&#8217;t much <br \/>fun&#8230;&quot;<br \/>&#8211; Cows with Guns by Dana Lyons<\/p>\n<p>The cows want to prove to the public that they are both smart and fun.  <br \/>In order to do this, Bessie has organized an exhibition that will be put <br \/>on by the cows. She has given each of the N (1 &lt;= N &lt;= 100) cows a <br \/>thorough interview and determined two values for each cow: the smartness <br \/>Si (-1000 &lt;= Si &lt;= 1000) of the cow and the funness Fi (-1000 &lt;= Fi &lt;= <br \/>1000) of the cow.<\/p>\n<p>Bessie must choose which cows she wants to bring to her exhibition. She <br \/>believes that the total smartness TS of the group is the sum of the Si&#8217;s <br \/>and, likewise, the total funness TF of the group is the sum of the Fi&#8217;s.  <br \/>Bessie wants to maximize the sum of TS and TF, but she also wants both of <br \/>these values to be non-negative (since she must also show that the cows <br \/>are well-rounded; a negative TS or TF would ruin this).  Help Bessie <br \/>maximize the sum of TS and TF without letting either of these values <br \/>become negative.<\/p>\n<p>PROBLEM NAME: smrtfun<\/p>\n<p>INPUT FORMAT:<\/p>\n<p>* Line 1: A single integer N, the number of cows<\/p>\n<p>* Lines 2..N+1: Two space-separated integers Si and Fi, respectively<br \/>        the smartness and  funness for each cow.<\/p>\n<p>SAMPLE INPUT (file smrtfun.in):<\/p>\n<p>5<br \/>-5 7<br \/>8 -6<br \/>6 -3<br \/>2 1<br \/>-8 -5<\/p>\n<p>OUTPUT FORMAT:<\/p>\n<p>* Line 1: One integer: the optimal sum of TS and TF such that both TS<br \/>        and TF are  non-negative.  If no subset of the cows has<br \/>        non-negative TS and non- negative TF, print 0.<\/p>\n<p>SAMPLE OUTPUT (file smrtfun.out):<\/p>\n<p>8<\/p>\n<p>OUTPUT DETAILS:<\/p>\n<p>Bessie chooses cows 1, 3, and 4, giving values of TS = -5+6+2 = 3 and TF <br \/>= 7-3+1 = 5, so 3+5 = 8.  Note that adding cow 2 would improve the value <br \/>of TS+TF to 10, but the new value of TF would be negative, so it is not <br \/>allowed.<\/p>\n<p>**********************************************************************<\/p>\n<p>PROBLEM 2: Milking Grid [Tom Widland, 2003]<\/p>\n<p>Every morning when they are milked, the Farmer John&#8217;s cows form a<br \/>rectangular grid that is R (1 &lt;= R &lt;= 10,000) rows by C (1 &lt;= C &lt;=<br \/>75) columns. As we all know, Farmer John is quite the expert on cow<br \/>behavior, and is currently writing a book about feeding behavior in<br \/>cows.  He notices that if each cow is labeled with an uppercase letter<br \/>indicating its breed, the two-dimensional pattern formed by his cows<br \/>during milking sometimes seems to be made from smaller repeating<br \/>rectangular patterns.<\/p>\n<p>Help FJ find the rectangular unit of smallest area that can be<br \/>repetitively tiled to make up the entire milking grid.  Note that the<br \/>dimensions of the small rectangular unit do not necessarily need to<br \/>divide evenly the dimensions of the entire milking grid, as indicated<br \/>in the sample input below.<\/p>\n<p>PROBLEM NAME: mgrid<\/p>\n<p>INPUT FORMAT:<\/p>\n<p>* Line 1: Two space-separated integers: R and C<\/p>\n<p>* Lines 2..R+1: The grid that the cows form, with an uppercase letter<br \/>        denoting each cow&#8217;s  breed. Each of the R input lines has C<br \/>        characters with no space or other  intervening character.<\/p>\n<p>SAMPLE INPUT (file mgrid.in):<\/p>\n<p>2 5<br \/>ABABA<br \/>ABABA<\/p>\n<p>OUTPUT FORMAT:<\/p>\n<p>* Line 1: The area of the smallest unit from which the grid is formed<\/p>\n<p>SAMPLE OUTPUT (file mgrid.out):<\/p>\n<p>2<\/p>\n<p>OUTPUT DETAILS:<\/p>\n<p>The entire milking grid can be constructed from repetitions of the <br \/>pattern &#8216;AB&#8217;. <\/p>\n<p>**********************************************************************<\/p>\n<p>PROBLEM 3: Popular Cows [Brian Dean, 2003]<\/p>\n<p>Every cow&#8217;s dream is to become the most popular cow in the herd.  In a <br \/>herd of N (1 &lt;= N &lt;= 10,000) cows, you are given up to M (1 &lt;= M &lt;= <br \/>50,000) ordered pairs of the form (A, B) that tell you that cow A thinks <br \/>that cow B is popular.  Since popularity is transitive, if A thinks B is <br \/>popular and B thinks C is popular, then A will also think that C is <br \/>popular, even if this is not explicitly specified by an ordered pair in <br \/>the input.  Your task is to compute the number of cows that are <br \/>considered popular by every other cow.<\/p>\n<p>PROBLEM NAME: popular<\/p>\n<p>INPUT FORMAT:<\/p>\n<p>* Line 1: Two space-separated integers, N and M<\/p>\n<p>* Lines 2..1+M: Two space-separated numbers A and B, meaning that A<br \/>        thinks B is popular.<\/p>\n<p>SAMPLE INPUT (file popular.in):<\/p>\n<p>3 3<br \/>1 2<br \/>2 1<br \/>2 3<\/p>\n<p>OUTPUT FORMAT:<\/p>\n<p>* Line 1: A single integer that is the number of cows who are<br \/>        considered popular by  every other cow.<\/p>\n<p>SAMPLE OUTPUT (file popular.out):<\/p>\n<p>1<\/p>\n<p>OUTPUT DETAILS:<\/p>\n<p>Cow 3 is the only cow of high popularity.<\/p>\n<p>**********************************************************************<\/p>\n<p>PROBLEM 4: Beauty Contest [Quynh Tran, 2003]<\/p>\n<p>Bessie, Farmer John&#8217;s prize cow, has just won first place in a bovine <br \/>beauty contest, earning the title &#8216;Miss Cow World&#8217;.  As a result, Bessie <br \/>will make a tour of N (2 &lt;= N &lt;= 50,000) farms around the world in order <br \/>to spread goodwill between farmers and their cows.  For simplicity, the <br \/>world will be represented as a two-dimensional plane, where each farm is <br \/>located at a pair of integer coordinates (x,y), each having a value in <br \/>the range  -10,000 &#8230; 10,000.  No two farms share the same pair of <br \/>coordinates.<\/p>\n<p>Even though Bessie travels directly in a straight line between pairs of <br \/>farms, the distance between some farms can be quite large, so she wants to<br \/>bring a suitcase full of hay with her so she has enough food to eat on <br \/>each leg of her journey.  Since Bessie refills her suitcase at every farm <br \/>she visits, she wants to determine the maximum possible distance she <br \/>might need to travel so she knows the size of suitcase she must bring.<br \/>Help Bessie by computing the maximum distance among all pairs of farms.<\/p>\n<p>PROBLEM NAME: msworld<\/p>\n<p>INPUT FORMAT:<\/p>\n<p>* Line 1: A single integer, N<\/p>\n<p>* Lines 2..N+1: Two space-separated integers x and y specifying<br \/>        coordinate of each farm<\/p>\n<p>SAMPLE INPUT (file msworld.in):<\/p>\n<p>4<br \/>0 0<br \/>0 1<br \/>1 1<br \/>1 0<\/p>\n<p>OUTPUT FORMAT:<\/p>\n<p>* Line 1: A single integer that is the squared distance between the<br \/>        pair of farms  that are farthest apart from each other.<\/p>\n<p>SAMPLE OUTPUT (file msworld.out):<\/p>\n<p>2<\/p>\n<p>OUTPUT DETAILS:<\/p>\n<p>Farm 1 (0, 0) and farm 3 (1, 1) have the longest distance (square root of <br \/>2)<\/p>\n<p>********************************************************************** <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uff2d\uff33\u5b98\u7f51\u4e0a\u6ca1\u6709\u4e86\u3002\u3002\u3002\u53d1\u8fd9\u5427\u3002\u3002\u3002********************************************************************** GREEN PROBLEMS********************************************************************** Four problems numbered 1 through 4********************************************************************** PROBLEM 1: Cow Exhibition [Brian Jacokes, 2003] &quot;Fat and docile, big and dumb, they look so stupid, they aren&#8217;t much fun&#8230;&quot;&#8211; Cows with Guns by Dana Lyons The cows want to prove to the public that they are both smart and fun. In order to do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/28"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=28"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}