luogu#P5107. 能量采集
能量采集
Problem Description
The statement has been modified. Please pay attention.
Please compute the following expression: , and take the answer modulo a large prime number.
Sorry, I read the wrong script.
You are given a directed graph with nodes and edges. Each node has an initial energy value .
Every second, the energy at each node flows equally to all of its outgoing edges. In addition, one share flows to itself (you may treat this as having a self-loop).
Now has queries. Each query gives a time , and wants to know the energy at each node after seconds.
The graph is not guaranteed to be free of multiple edges or self-loops. All answers are taken modulo .
Input Format
The first line contains three integers, .
The second line contains integers, from to , representing the initial energy.
The next lines each contain two positive integers , representing a directed edge from to . We assume the nodes are numbered from to .
The next lines each contain one positive integer , representing a query.
Output Format
To avoid overly large output, for each query you only need to output one line with one non-negative integer, which is the XOR sum of the energies (modulo) of the nodes, and then taken modulo .
5 10 3
4 5 3 2 7
4 1
1 4
2 1
3 2
1 2
5 1
2 4
2 1
2 4
1 4
1
2
3
15
548614965
80769513
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, $1\le n\le 50,1\le m\le n\times (n-1),1\le q\le 5\times 10^4,0< a_i< 998244353,1\le t\le 10^9$.
Translated by ChatGPT 5