#P11143. 「SFMOI Round I」Strange Cake Game
「SFMOI Round I」Strange Cake Game
Description
There is a rectangular cake with an area of . Its upper-left vertex is represented as , and the bottom-right vertex is represented as .
There are chocolates on the cake. The position of the -th chocolate is . There may be more than one chocolate at the same position.
Little M and Little W are going to cut the cake with a cake knife. At the very beginning, the knife is positioned at . Little M and Little W are taking turns to move the knife, with Little W going first. Let's say the knife is at , and it can be moved to or in a turn.
After several turns, the cake will be cut into two parts — the upper-right part belongs to Little W, and the other part belongs to Little W. Both Little W and Little M want to have the most chocolates, so please help them determine: if both of them move the knife optimally, how many chocolates Little W will have.
The following picture shows a cake and a possible way of cutting the cake.

Input Format
The first line contains two integers — the position of the bottom-right vertex of the cake.
The following line contains — number of the chocolates.
Next lines, the -th line contains two integers — the position of -th chocolate is .
Note that There may be more than one chocolate at the same position.
Output Format
A single integer — the number of chocolates that Little W will have if they move the knife optimally.
3 3
1
1 3
1
Hint
Subtasks and Contraints
- Subtask 1 (5 pts): ;
- Subtask 2 (10 pts): ;
- Subtask 3 (15 pts): ;
- Subtask 4 (20 pts): ;
- Subtask 5 (50 pts): No further constraints.
It is guaranteed that
- ;
- ;
- , .
京公网安备 11011102002149号