luogu#P11257. [GDKOI2023 普及组] 交换机
[GDKOI2023 普及组] 交换机
Problem Description
Moon is preparing for the beginning-of-term exam on computer networks and is reviewing knowledge about switches. A switch has an amazing feature: its table is built automatically, dynamically, and autonomously, meaning there is no intervention from a network administrator or any configuration protocol. In other words, the switch is self-learning. This ability is roughly implemented in the following way:
- The switch table is initially empty.
- For every frame received on each interface, the switch stores the source address of the frame in its table.
- If, after a period of time (called the aging time), the switch does not receive any frame containing a certain source address, it deletes that source address from the table.
Now you are given all frames received by a switch during one day (each frame contains a source address and the arrival time of the frame). Please help Moon compute the minimum number of entries the switch table needs during that day, so that the information of all frames can be stored. Note: for simplicity, at each time point, perform deletions first and then insertions.
In simple terms, you need to maintain a string set . There are several insertion operations; each insertion contains a string and a valid time interval (with a fixed length). You need to find, over all times, the maximum size of the string set .
Input Format
The first line contains two integers , representing the number of frames and the aging time (in minutes), respectively.
The next lines each contain two strings , representing the source address contained in the frame and its arrival time. Here, is a MAC address consisting of hexadecimal digits, and has the format , where and . This means the frame arrives at the switch at hour , minute , and second . If or is less than , a leading zero is added.
Output Format
One line with one integer, representing the answer.
4 10
0123456789ABCDEF 00:10
0000000000ABCDEF 08:11
0123456789ABCDEF 00:15
0000000000ABCDEF 00:11
2
3 60
0123456789ABCDEF 13:00
0000000000000000 14:00
0123456789ABCDEF 12:30
1
见/example/switch/下的 switch1.in
见/example/switch/下的 switch1.out
Hint
Sample Explanation
In sample , at time , there are source addresses in the table: and . Therefore, the required table size must be at least , and it can be proven that this is the minimum required size.
Constraints
For all testdata, and .
For of the testdata, .
Translated by ChatGPT 5