#P5486. [JLOI2010] 世界杯租房

    ID: 6232 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP2010各省省选吉林区间 DP

[JLOI2010] 世界杯租房

Problem Description

The South Africa World Cup organizing committee designated some hotels that could provide rooms for fans to rent during this period, and one of them is called Avatar. Since the number of rooms in the Avatar hotel does not exceed 2626, they can be represented by 2626 uppercase letters.
One day, Manager Liu’s phone rang. He received a request to rent a room from the night of June 12 to noon of June 19. He checked the reservation table, but did not find any single room that could satisfy the request directly. For example, the owner might need to stay in their own room for personal reasons, so the tourist has to stay in one room for a few days and then move to another room for the remaining days. After carefully checking the reservation table, he told the traveler: “I will place you in BB for 33 days first, and then arrange you to stay in FF for the rest of the trip.”
Your goal is to minimize the number of times the traveler needs to move from one room to another.
Note that in the hotel’s billing, the time from one night to the next day at noon is always counted as one day.

Input Format

The input contains multiple test cases. For each test case, the first line contains two integers MM and NN. MM is the number of days on the schedule, and NN is the number of units (rooms). The number of days does not exceed 100100, counted starting from 11. The number of units does not exceed 2626, labeled starting from AA.

The next MM lines each contain NN letters, indicating whether the unit has already been rented from the night of day ii to noon of the next day. X means rented, and O means not rented.

The last line contains two integers s,ts, t, meaning the traveler checks in on the night of day ss and ends the trip at noon of day (t+1)(t+1). 1s<tM+11\leq s<t\leq M+1.
M=N=0M=N=0 indicates the end of the file.

Output Format

For each test case, first print the testdata number, followed by a colon and a blank line. Then output a plan with the minimum number of room changes, using the following format on each line:

<unit>: <start date>-<end date>

Here, <unit> is the unit label, and <start date> and <end date> are the times when the traveler moves into and leaves that unit, respectively.

Note that if there are multiple plans with the minimum number of room changes, output the lexicographically smallest plan.

If no such plan exists, output one line: Not available.

Print a blank line between every two test cases. Do not add an extra blank line at the end of the output.

10 7
XXXXXXX
XOXXXXO
XOXXXXO
XOXXXOX
OXXOXOX
XOXOXOX
OXXOXOX
OXXXXOX
XXXXXXX
XXXXXXX
2 9
0 0
Case 1:

B: 2-5
F: 5-9

Hint

Translated by ChatGPT 5