luogu#P6398. [COI 2008] KOLEKCIJA
[COI 2008] KOLEKCIJA
Problem Description
Igor has a playlist containing songs, numbered from to . Today he is going to listen to songs.
When playing the -th song, the information of consecutive songs will be shown in a list. These consecutive songs must include the -th song, and there are no other requirements.
When a song is shown in the list, its information will be read once. If a song is shown in the list multiple times, its information will only be read once (no matter whether the two displays are consecutive).
Please give a plan that makes the number of songs whose information gets read as small as possible.
Input Format
The first line contains two integers, representing the number of songs in the playlist and the given parameter .
The second line contains one integer, representing the number of songs Igor will listen to, .
Lines to each contain one integer, representing the index of the -th song Igor will listen to.
Output Format
This problem uses a Special Judge.
In the first line, output an integer , the minimum number of times song information is read.
In lines to , output two integers per line. On line , output , meaning that when listening to the -th song, the information of songs from to is displayed.
Your output must satisfy , , and the number of songs read according to your plan is .
10 3
5
4
5
8
7
6
5
4 6
4 6
6 8
6 8
6 8
15 4
6
6
14
11
3
8
5
10
3 6
11 14
11 14
3 6
5 8
3 6
1000 301
3
300
500
700
401
300 600
350 650
400 700
Hint
Constraints
For all test cases, it is guaranteed that:
- , .
- , and all are pairwise distinct.
Scoring
- If the number of output numbers is less than , or the number in the first line is different from the answer, you will get of the score for that test point.
- If is the same as the answer but the output plan is incorrect, you will get of the score for that test point.
- If is the same as the answer and the output plan is correct, you will get of the score for that test point.
Notes
This problem is translated from COCI2007-2008 COI2008 T2 KOLEKCIJA. The translation and SPJ are provided by 一扶苏一.
Translated by ChatGPT 5