#P8323. 『JROI-4』傀影与猩红孤钻
『JROI-4』傀影与猩红孤钻
Description
We provide a formal statement at the bottom of the Description. If you do not want to read the roleplay part, you can directly jump to the bottom of the Description.
God retrieved a part of His power during the exploration of the Crimson Troupe. Not much, but enough.
God met Phantom, and prepared to judge him with Brilliant Shards.
However, Phantom hid in a DAG that is divided into layers.
Specifically, nodes in layer of the DAG only have edges pointing to nodes in layer .
“Then I will keep playing with you,” God thought.
God decided on a way to carry out the judgment.
Specifically, God initially has some Brilliant Shards. God believes that polynomials have great power, so Brilliant Shards are polynomials. I am not telling you it is because I am too lazy to make up the story.
God has three operations on Brilliant Shards:
- “No Degree”
It can make a Brilliant Shard stronger. Specifically, applying this operation to is equivalent to setting .
- “Continuation of Civilization”
It can make the Brilliant Shard after “No Degree” even stronger. Specifically, applying this operation to is equivalent to setting .
- “Night Terror”
It can merge two Brilliant Shards and make them stronger. Specifically, applying this operation to and returns a polynomial .
God judges Phantom in the following way:
Place Brilliant Shards on the nodes in the first layer.
Before a Brilliant Shard enters a node, it applies “No Degree” to itself.
When two Brilliant Shards meet, apply “Night Terror” to these two Brilliant Shards. Only one Brilliant Shard remains, which is the result of applying “Night Terror” to the two.
A Brilliant Shard will only leave a node after Brilliant Shards have passed through all edges connected to that node. When a Brilliant Shard leaves a node, it applies “Continuation of Civilization,” then splits into several Brilliant Shards identical to the original one, leaving one Brilliant Shard at that node. Then, each edge will be passed through by exactly one Brilliant Shard.
If Phantom is at node , and God has an execution points (EXP) , and the Brilliant Shard left at that node is , then Phantom will be struck by an electric current of volts.
Now God has some queries. Each query is like: if Phantom is hiding at node , and the execution points is , then how many volts of current will Phantom receive?
God is merciful. The answer may be too large, so you only need to output the result modulo (a prime).
Formal Statement
You are given a DAG divided into layers. Each node has a polynomial . There may be multiple edges.
In this DAG, nodes in layer only have edges to nodes in layer .
Let contain all nodes that have edges pointing to node . Then it holds that .
You are given the polynomials of the nodes in the first layer. Each query gives , and asks for modulo (a prime).
Please note that multiple edges count as one edge.
Input Format
The first line contains an integer , representing the number of layers of the DAG.
The next line contains integers. The -th number indicates that there are nodes in layer .
The next lines describe the polynomials of the nodes in the first layer. In the -th line, there are several numbers representing the polynomial of node in the first layer.
Specifically, the first number in each line is , the highest degree of the polynomial. The next numbers are the coefficients of the polynomial. If the -th of these numbers (excluding ) is , then the polynomial is .
The remaining input is divided into blocks. At the beginning of block , there are two numbers , meaning there are edges from layer , and God has queries among the nodes in layer .
The next lines each contain two numbers , indicating that the node numbered in layer connects to the node numbered in layer .
The next lines each contain two integers , indicating that God asks: when Phantom is at node in layer , and the execution points is , output the volts of current Phantom receives modulo .
Output Format
Since the output may be too large, you need to encrypt the output.
Specifically, for the queries in layer , if the answer to the -th query is , you only need to output $(k \times \bigoplus_{i=1}^q(q-i) \times a_i)\bmod 2^{32}$.
Note that there are exactly lines of output, one number per line.
3
1 2 2
1 1 1
2 1
1 1
1 2
1 3
3 2
1 1
1 2
2 2
2 5
1 36
0 2
1 7
2 6
0
1352
10488222
//下面是加密前的输出
4
676
1682209
3496074
4354184
Hint
- Subtask 1 (7 pts): .
- Subtask 2 (20 pts): .
- Subtask 3 (13 pts): , and the time limit is 5 s.
- Subtask 4 (60 pts): no special restrictions.
- Subtask 5 (0 pts): hack testdata.
For of the testdata, , , , , .
If layer has edges, then for it is guaranteed that and , and .
Translated by ChatGPT 5
京公网安备 11011102002149号