#P6016. [CSGRound3] 出游
[CSGRound3] 出游
Description
The school organized a summer trip, and registration will close on day .
There are students. Student has friends. The friendship relation is directed. In other words, if student Z has student Y as a friend, it does not mean student Y must have student Z as a friend. Also, a student may be their own friend.
On day , each student decides whether to join the trip. Student decides to join with probability , and decides not to join with probability .
During the next days, each student will decide again whether to join. On that day, student decides to join if and only if at least one of their friends decided to join on the previous day; otherwise, they do not join.
You need to compute the expected number of students who join the trip. Output the answer modulo .
Input Format
The first line contains two integers , as described above.
The next lines each start with two integers . Here, is the probability (under modulo ) that student decides to join on day , and is the number of their friends. Then follow integers indicating their friends.
Output Format
Output one integer, the answer modulo .
3 1
1 2 2 3
0 1 3
499122177 1 2
1
3 3
1 2 2 3
0 1 3
233 1 2
466
Hint
[Sample 1 Explanation]
| Day | Probability that the first student goes | Probability that the second student goes | Probability that the third student goes |
|---|---|---|---|
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (3 points): .
- Subtask 2 (14 points): .
- Subtask 3 (33 points): .
- Subtask 4 (20 points): .
- Subtask 5 (15 points): .
- Subtask 6 (15 points): No special constraints.
For of the testdata: , , , , and all friends are distinct.
Translated by ChatGPT 5
京公网安备 11011102002149号