USACO translation: USACO 2013 JAN Three Issues (1)

USACO JAN 2013

I, entitled Overview

Chinese title name

mirror

Paint the fence

    Cows line up

English title name

mirrors

paint

lineup

Executable file name

mirrors

paint

lineup

Enter the file name

mirrors.in

paint.in

lineup.in

Output filename

mirrors.out

paint.out

lineup.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

128 M

128 M

128 M

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

 

1. Mirror {Bronze title 1}

【Problem Description】

Farmer John installed N (1 <= N <= 200) with a mirror fences, he wants to see where the coordinates (a, b) from bovine coordinates (0,0) in the home.

Fences integer coordinates (x_i, y_i), the shape of the '/' or '\' 45 degree segments, such as coordinates (3,5) '/' shaped barrier may be described as (2.9,4.9) to (3.1, 5.1) segment. Each barrier located at different positions, the coordinates of the range [-1,000,000..1,000,000], (0,0) and (a, b). At no fence.

Farmer John at (0,0), facing the + X direction, he wants to see through the fence mirror (a, b) in the case. Unfortunately, he may have put the wrong shape of a mirror in which, find and adjust the mirror so that he would be able to see that (a, b) in the case of cattle.

[File Input]

The first row of three integers N, a, b.

Next 2..N + 1 lines of three integers, respectively, and coordinates of a shape.

[File Output]

   The output common line, an integer representing the number of adjustment of the mirror. If you need to adjust the output 0, if the adjustment still can not see the output -1.

[Sample input]

5 6 2

3 0 /

0 2 /

1 2 /

3 2 \

1 3 \

[Sample Output]

4

[Sample Description]

The coordinates (3,2) of the mirror from \ adjusted to /.

 

2. fence paint {silver title 1}

【Problem Description】

   Farmer John in Bessie the cow's body tied to a paint bucket and tied a brush, ordered him running along the edge of the fence, in order to paint a fence.

  Fence as a one-dimensional line segment, beginning at position 0 Bessey, he will receive a command N (1 <= N <= 100,000), each command of the form: "10 L": 10 moves to the left unit, "15 R": 15 units move right. For a given sequence of commands, Farmer John would like to know how many units the length of the fence by at least K times the paint brush. Bessie will leave the starting position up to 1,000,000,000 units.

[File Input]

The first line, two integers N and K.

Next, 2 to line N + 1, N commands described

[File Output]

An integer, K represents the number of times at least brush fence.

[Sample input]

6 2

2 R

6 L

1 R

8 L

1 R

2 R

[Sample Output]

6

[Sample Description]

6 fence unit length is at least 2 times the paint brush, are [-11, -8], [-4, -3], [0,2].

3. Cow queuing {Gold title 1}

【Problem Description】

Farmer John N (1 <= N <= 100,000) cows lined up a team, with each cow are compiled on a "descent number", this number is an integer ranging from 0 ... 1,000,000,000. The same lineage have the same number of cows, cows that is likely to have the same "blood numbers." 
   John felt that if some cows continuously aligned with the same number of descent, then the cows will look more mighty. In order to create such a continuous period up to elect John cows k kinds of blood, and put them all away from the queue. 

Please help John to do this calculation can be obtained from the same number of cattle descent constitute the largest segment of the continuous length is how many?

[File Input]

The first line, two spaces integers N and K interval.

Next N rows, each row an integer representing the number corresponding to the cow blood.

[File Output]

    Line length, an integer that can be expressed to give the maximum continuous section

[Sample input]

9 1

2

7

3

7

7

3

7

5

7

[Sample Output]

4

[Sample Description]

Sample description, only one kind of cow delete, delete number 3 cow origin obtainable 2,777,757, which is the longest stretch of consecutive numbers 7 4.

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

Guess you like

Origin blog.csdn.net/weixin_33836874/article/details/93452773