#P11055. Yet another ZP problem
Yet another ZP problem
Problem Description
There are points arranged from left to right, numbered .
You need to add some edges between them, and denote the edge set as .
We say that the edge set satisfies the constraint if and only if there exists such that .
Basically, we require that for all , the constraint is satisfied.
On top of that, the input gives additional constraints ( and ).
What is the minimum possible ? Also, based on that, output one valid construction. It can be proven that a valid always exists.
For an expression of the form , its value is if and only if the proposition is true; otherwise, its value is .
Input Format
The first line contains two integers .
The next lines each contain two positive integers .
Output Format
The first line output one number representing .
The next lines each contain two numbers representing an edge. Note that you must ensure .
4 3
1 2
3 4
1 2
2
1 4
2 3
Hint
Sample Explanation
For the constraint , there is an edge such that .
For the constraint , there is an edge such that .
For the constraint , there is an edge such that .
Constraints
For all testdata, it is guaranteed that , , , and .
| Test Point ID | Special Property |
|---|---|
| None |
For the -th test point, it is guaranteed that the parity of is the same as the parity of , and the parity of is the same as the parity of .
Translated by ChatGPT 5