#P9590. 「PFLOI R1」PFL 团主的 PFL 操作
「PFLOI R1」PFL 团主的 PFL 操作
Background
After the contest ended, Zhili, Yangmai, Huamao invited Duanyao, and the four became friends from then on.
In fact, not only Duanyao, but also Zhili, Yangmai, and Huamao were once the strongest in the OI community. After getting AK again and again in one Trash Round after another, they got tired, disappeared from the scene, and quit the world of OI.
Today, seeing that Duanyao is still as talented as before, they again think of those times spent with OI... and excitement rises in their hearts.
So they found Junjun, the leader of PFLOI, and asked Junjun to give them a chance to shine again—by holding a contest of their own.
After hearing their stories, Junjun was deeply moved and gladly agreed. The five of them gathered in PFLOI.
But after Yangmai joined PFLOI, making problems randomly being too naughty, Junjun was not happy, so:


Problem Description
There are operations. In each operation, one of the following events happens with equal probability:
- Add into the team. After the operation, becomes a member.
- Kick out of the team.
- Set as an administrator.
- Set as a member.
Note:
- Initially, nobody is in the team.
- If is not in the team, then operations 2, 3, 4 have no effect.
- If is a member, then operations 1 and 4 have no effect.
- If is an administrator, then operations 1, 2, 3 have no effect.
Finally, output the expected number of administrators in the team, modulo .
Input Format
The first line contains an integer .
If is , use the first input method; otherwise, use the second input method.
First input method:
The first line contains a positive integer .
The second line contains integers representing the array .
Second input method:
A single line contains four integers .
Note: In the second input method, you need to compute the array , which satisfies .
Output Format
Output one integer representing the expected number of administrators in the team, modulo .
1
6
1 1 2 1 2 1
760381441
2
11 4 5 14
686292993
Hint
This problem uses bundled tests.
| Subtask ID | Score | |||
|---|---|---|---|---|
| Subtask ID | Score | |||
|---|---|---|---|---|
For all testdata, .
Translated by ChatGPT 5