#P1657. 选书
选书
Description
When school goes on winter break, the informatics olympiad coach has books to distribute to trainees. Each person can receive only one book, but each person has two favorite books.
The teacher first asks each person to write down the books they like on a sheet. Then, based on these sheets, the teacher assigns the books. Please write a program to find the total number of possible assignment schemes in which every student is satisfied.
Input Format
Line : a number .
Lines through : each line contains two numbers, indicating the indices of the books that likes.
Output Format
A single number: the total number of schemes .
5
1 3
4 5
2 5
1 4
3 5
2
Hint
Constraints
For all testdata, .
, Ruan Xingzhi
In the original testdata for this problem, the last data point has equal to , and the expected output is . Considering this data is unreasonable, it has been removed. Now, when submitting this problem, you will not encounter data points with .
Translated by ChatGPT 5
京公网安备 11011102002149号