#P1499. [CTSC2000] 公路巡逻

    ID: 490 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp2000WC/CTSC/集训队枚举,暴力

[CTSC2000] 公路巡逻

Description

On a straight highway with no forks, there are nn checkpoints, and the distance between any two adjacent checkpoints is 10km10\rm km . All vehicles on this highway have a minimum speed of 60km/h60\rm km/h and a maximum speed of 120km/h120\rm km/h, and they may change speed only at checkpoints.

Patrolling is performed as follows: at some time TiT_{i}, a patrol car is dispatched from checkpoint nin_{i}, travels at a constant speed to checkpoint ni+1n_{i}+1, and spends tit_{i} seconds on the road.

Two cars are considered to have met if one overtakes the other or if both arrive at the same checkpoint at the same time (departing at the same time does not count as a meeting).

The patrol department wants to know the minimum number of patrol cars that a car (the “target car”) departing from checkpoint 11 at exactly 66 o’clock to checkpoint nn will meet. Please write a program to compute this. Assume that all vehicles arrive at checkpoints at integer seconds.

Input Format

The first line of the input file contains two integers, the number of checkpoints nn and the number of patrol cars mm.

Each of the next mm lines describes one patrol car (sorted by increasing starting position). The format is nin_{i}, TiT_{i}, tit_{i}, representing the ii-th patrol car’s starting position, departure time, and time spent on the road, respectively. Here nin_{i} and TiT_{i} are integers. TiT_{i} has the form HHMMSS, representing hour, minute, and second in 24-hour time; numbers with fewer than two digits are padded with a leading 0.

Output Format

The first line of the output file is the number of meetings between the target car and the patrol cars.

The second line is the earliest arrival time at checkpoint nn when the number of meetings is minimized (format is the same as TiT_{i} in the input).

3 2
1 060000 301
2 060300 600

0
061301

Hint

Constraints: 1<n<501 < n < 501<m<3001 < m < 3001ni<n1 \leq n_{i} < n300ti600300 \leq t_i \leq 600,all TiT_i are no earlier than 05:00 and no later than 23:00.

CTSC 2000 First Session.

Translated by ChatGPT 5