#P3921. 小学数学题
小学数学题
Description
Rumia: There are fairies who want to cross Mist Lake. Because the lakeside is covered in thick fog, the fairies cannot tell how big the lake is and do not want to walk around the edge.
There is a boat teleporter on the lake, and each time this teleporter can carry at most fairies across the lake (note that the teleporter can simultaneously send fairies from both sides to the opposite side, but the total number moved in one operation must not exceed ).
These fairies love to make trouble, so at all times the following conditions must be satisfied. There are conditions of the first type and conditions of the second type.
First type: Fairy and fairy must be on the same side of the lake.
Second type: When fairy is on one side of the lake, fairies and must not be simultaneously on the other side.
Given these conditions, find:
- The minimum number of times the teleporter must be used to move all fairies to the opposite shore.
- Under the constraint of using the minimum number of times, the number of valid crossing plans.
Input Format
The first line contains four integers .
Each of the next lines contains two integers , representing a condition of the first type.
Each of the next lines contains three integers , representing a condition of the second type.
Output Format
Output two integers: the minimum number of uses of the teleporter and the number of valid plans, separated by a space.
If it is impossible for all fairies to cross, output -1 0.
1 0 0 1
1 1
5 0 0 2
3 90
3 1 0 1
1 2
-1 0
Hint
- For of the testdata, .
- For another of the testdata, .
- Constraints: For of the testdata, , , .
Please do not rely on the Luogu judge’s speed. If you score above , you can submit again when there are fewer users. But if you score below , it probably is not the correct solution, so please do not put extra load on the judge.
Translated by ChatGPT 5
京公网安备 11011102002149号