USACO translation: USACO 2014 US Open Three Questions

USACO 2014 US Open

I, entitled Overview

Chinese title name

Ranch decoration

odometer

Like cattle exhibition

English title name

decorate

odometer

fairphoto

Executable file name

decorate

odometer

fairphoto

Enter the file name

decorate.in

odometer.in

fairphoto.in

Output filename

decorate.out

odometer.out

fairphoto.out

Each test point of time limit

1 second

1 second

1 second

The number of test points

10

10

10

Each test point score

10

10

10

Compare the way

Compare the full text

Compare the full text

Compare the full text

Second, run the memory limit

Run memory limit

256 M

256 M

256 M

      Note: Thanks Hu full translation. [Error there, the statement is not so smooth ......]

 

1. ranch decorative {bronze title 3}

【Problem Description】

Farmer John has N (1 <= N <= 50,000) pastures, numbered 1 ... N. Ranch connected by M (1 <= M <= 100,000) bidirectional path. I road connecting two different grazing pastures A_i (1 <= A_I <= N) and pasture B_i (1 <= B_i <= N). Between the same pair of pasture may be multiple road links.

Now place a ranch marked on each capital letter "F" or "J" billboards decorated. There are two connected ranch road, it must be placed in different letters of billboards.

"F" letter billboard price is higher than the "J" letter of billboards, so John wanted to maximize the use of "J" letter billboard, please output the maximum number, if no feasible solutions put, the output "-1".

[File Input]

The first two acts of integers N and M.

Next 2..M lines of two integers, describing the M two-way road.

[File Output]

   The output common line, a integer indicating "J" the maximum number of letters billboard, no solution is "-1."

[1] Sample input

4 4

1 2

2 3

3 4

4 1

[1] Sample Output

2

Sample Description [1]

Ranch 1 and 3 or 2 and 4 use pastures "J" letter billboard.

 

 

2. odometer {silver title 3}

【Problem Description】

John's cattle farmers are starting a wonderful journey. A represents an integer of display mileage, mileage of the journey begins when X (100 <= X <= 10 ^ 18) on the odometer ox cart, at the end of mileage to Y (X <= Y <= 10 ^ 18). Whenever the odometer display an interesting number (including start and end number), it will issue a cattle pleasant sounds.

An interesting number for each, the same as if at least half the number of a number of miles, then the mileage. For example: 3223 is 110 and the number of interesting, but not 123 and 97,791.

Calculate the whole journey, how many cattle they eat will be issued pleasant sounds.

[File Input]

    Co-line, separated by two spaces is an integer indicating X and Y.

[File Output]

    Total row, an integer that indicates the number of cattle call.

[1] Sample input

110 133

[1] Sample Output

14

Sample Description [1]

Interestingly, the number of these 14 are:

110, 111, 112, 113, 114, 115, 116,

117, 118, 119, 121, 122, 131, 133。

3. Bovine like exhibition {gold title 1}

【Problem Description】

Farmer John's N (1 <= N <= 100,000) cow was standing in a line to take pictures. Cow standing in the i-th position x_i (the integer 0..1,000,000,000), b_i per cow by an integer (integer 1..8) is represented in variety. No two cows standing in the same position.

Farmer John wishes to photograph a continuum in cattle, in order to participate in the exhibition. For fairness, the number of cattle he wants all varieties within the same interval, while containing at least K (K> = 2) of the bovine species, calculate the condition of the photo maximum length, the maximum length is the the length of the interval.

[File Input]

The first line, separated by a space of two integers, respectively, and N K.

2 through line 1 + N, in each row two integers, represent the i-th position and cow species.

[File Output]

    Total row, an integer that represents the maximum length photograph. If no solution outputs -1.

[1] Sample input

9 2

1 1

5 1

6 1

9 1

100 1

2 2

7 2

3 3

8 3

[1] Sample Output

6

Sample Description [1]

Interval [2..8] contains three cattle (1,2,3 respectively), as are the number 2.

 

 

Reproduced in: https: //www.cnblogs.com/jznoi/p/4058921.html

Guess you like

Origin blog.csdn.net/weixin_34191734/article/details/93452771