#P15565. [COCI 2025/2026 #5] 剪刀 / Škare
[COCI 2025/2026 #5] 剪刀 / Škare
Background
The full score for this problem is .
Problem Description
To master the skill of using scissors, Fran came up with a new training method.
He has a paper strip of length centimeters and a pair of scissors, and he asks Lana to give him cutting instructions.
Lana will give Fran a total of instructions, each of the form: “Cut the -th strip at a point centimeters from the left end.”
At the beginning, Fran has only one strip. After the first cut, it becomes two pieces with lengths and . After that, each time he cuts one piece, the two newly created pieces replace the original piece and stay in the same position in the sequence.
More formally: suppose there are currently strips with lengths in order. If Lana tells him to cut the -th strip at centimeters, then the new sequence becomes: $a_1,a_2,\dots,a_{x-1},\,l,\,a_x-l,\,a_{x+1},\dots,a_m$.
After all cuts are done, they want to verify whether the process was correct. One way is to count how many different strip lengths appear in the final sequence. Please compute this number.
Input Format
The first line contains two natural numbers (,), representing the original strip length and the number of instructions.
The next lines each contain two natural numbers (, and , where is the length of the -th strip at that time), meaning to cut the -th strip from left to right at centimeters from its left end.
Output Format
Output one line with an integer, representing how many different lengths of strips remain after all cuts are completed.
5 1
1 2
2
6 2
1 4
1 2
1
10 3
1 2
2 3
3 2
2
Hint
Sample Explanation
Explanation for Sample #1: .
Explanation for Sample #2: .
Explanation for Sample #3: .
Subtasks
| Subtask | Score | Constraint |
|---|---|---|
| For all , | ||
| For all , | ||
| No additional constraints |
Translated by ChatGPT 5