Usaco 2014 US Open
I. Question Overview
Chinese question name |
Pasture Decoration |
ODPS table |
Niuxiang Exhibition |
English question name |
Decorate |
Odometer |
Fairphoto |
Executable File Name |
Decorate |
Odometer |
Fairphoto |
Input File Name |
Decorate. In |
Odometer. In |
Fairphoto. In |
Output file name |
Decorate. Out |
Odometer. Out |
Fairphoto. Out |
Time limit for each test point |
1 second |
1 second |
1 second |
Number of test points |
10 |
10 |
10 |
Score of each test point |
10 |
10 |
10 |
Comparison Method |
Full text comparison |
Full text comparison |
Full text comparison |
Ii. Running memory limit
Maximum running memory |
256 m |
256 m |
256 m |
Note: Thank you for your translation. [Errors may occur, and the statements are not so fluent ......]
1.Pasture Decoration{BronzeQuestion3}
[Problem description]
Farmer John has n (1 <= n <= 50,000) pastures numbered 1... n. Pasture is connected by M (1 <= m <= 100,000) bidirectional roads. Road I connects two different pasture a_ I (1 <= a_ I <= N) and pasture B _ I (1 <= B _ I <= N ). There may be multiple road connections between the same farm.
Now, each farm is decorated with a billboard with an uppercase letter "F" or "J. Two pastures connected by roads must have billboards with different letters.
The price of the "f" letter billboard is higher than that of the "J" letter billboard, so John wants to maximize the use of the "J" letter billboard, please output this maximum number, if there is no feasible placement scheme, "-1" is output ".
[File input]
The first behavior is two integers, N and M.
Next line 2. M, two integers in each line, describes M bidirectional roads.
[File output]
The output is a row in total. An integer indicates the maximum number of "J" letter billboards. If there is no solution, "-1" is output ".
[Example 1]
4
1 2
2 3
3 4
4 1
[Output Example 1]
2
[Example 1]
Farm 1 and 3, or farm 2 and 4 use the "J" letter billboard.
2.ODPS table{SilverQuestion3}
[Problem description]
Farmer John's ox is starting a wonderful journey. An integer is displayed in the mileage table of the ox's car. The mileage is X (100 <= x <= 10 ^ 18) at the start of the journey ), the End Time is Y (x <= Y <= 10 ^ 18 ). When an ODPS table shows an interesting number (including the number of start and end points), the ox will make a pleasant call.
For each digit of a mileage, if at least half of the number is the same, the mileage is an interesting number. For example, 3223 and 110 are interesting numbers, while 97791 and 123 are not.
Calculate how many pleasant calls the cows will make throughout the journey.
[File input]
In a row, the two are separated by spaces and are integers, representing X and Y.
[File output]
A total of rows. An integer indicates the number of bits.
[Example 1]
110 133
[Output Example 1]
14
[Example 1]
The 14 interesting numbers are:
110,111,112,113,114,115,116,
117,118,119,121,122,131,133.
3.Niuxiang Exhibition{GoldQuestion1}
[Problem description]
Farmer John's n (1 <= n <= 100,000) cows lined up in a row. The I-header is located at X_ I (an integer of 0 .. 1,000,000,000), and each ox is represented by an integer B _ I (an integer of 1 .. 8. No two cows stand in the same position.
John, a farmer, wants to photograph a cow in a continuous interval to attend the exhibition. To be fair, he hopes that the number of cattle of each breed in this range will be the same, and at least K (k> = 2) cattle of the same breed will be included, calculate the maximum length of the photo that meets the conditions. The maximum length is the length of the range.
[File input]
In the first line, the two integers separated by spaces represent N and K respectively.
Line n + 1 and each line have two integers, indicating the position and breed of the nth ox, respectively.
[File output]
A total of rows. An integer indicates the maximum length of the photo. If no solution is available,-1 is output.
[Example 1]
9 2
1 1
5 1
6 1
9 1
100 1
2 2
7 2
3 3
8 3
[Output Example 1]
6
[Example 1]
The interval [2 .. 8] contains three kinds of cattle (numbers 1, 2, and 3), and the quantity is 2.
Usaco 2014 US Open Question