33OJ
登录 注册

#P17898. [ICPC 2026 Nanchang I] Legacy Code

    ID: 20634 远端评测题 8000ms 1024MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>数学倍增原根数论矩阵加速江西矩阵乘法ICPC2026省赛/邀请赛大步小步算法 BSGS

[ICPC 2026 Nanchang I] Legacy Code

Problem Description

You have a piece of legacy code:

$$\begin{array}{l} \textbf{for } t = 1 \textbf{ to } k \textbf{ do} \\ \qquad a_{x_1} \leftarrow (a_{u_1} \times a_{v_1}) \bmod MOD \\ \qquad a_{x_2} \leftarrow (a_{u_2} \times a_{v_2}) \bmod MOD \\ \qquad a_{x_3} \leftarrow (a_{u_3} \times a_{v_3}) \bmod MOD \\ \qquad \vdots \\ \qquad a_{x_m} \leftarrow (a_{u_m} \times a_{v_m}) \bmod MOD \\ \textbf{end for} \end{array}$$

where MOD=998 244 353MOD = 998\,244\,353 and xi,ui,vi∈{1,…,n}x_i, u_i, v_i \in \{1, \dots, n\} for i=1,…,mi = 1, \dots, m.

Given the initial values of the variables a1,a2,…,ana_1, a_2, \dots, a_n, compute their final values after the loop runs kk times. You need to answer qq such queries.

Input Format

The first line contains three integers nn, mm and qq (1≤n≤2001 \leq n \leq 200, 1≤m≤2×1051 \leq m \leq 2 \times 10^5, 1≤q≤2001 \leq q \leq 200).

The next mm lines each contain three integers xix_i, uiu_i, viv_i (1≤xi,ui,vi≤n1 \leq x_i, u_i, v_i \leq n).

Each of the next qq lines represents a query. Each query contains n+1n+1 integers:

  • the number of iterations kk (1≤k≤1061 \le k \le 10^6),
  • the initial values of the nn variables a1,a2,…,ana_1, a_2, \dots, a_n (0≤ai<998 244 3530 \le a_i < 998\,244\,353).

Output Format

For each query, output a single line containing nn integers --- the final values of a1,a2,…,ana_1, a_2, \dots, a_n after executing the code, each modulo 998 244 353998\,244\,353.

7 8 4
3 1 2
4 3 3
5 6 7
7 1 3
2 2 2
6 6 2
1 5 6
7 7 7
1 2 1 1 1 1 1 1
2 1 2 3 4 5 6 7
3 1 1 0 1 0 1 0
100 11 45 14 19 19 8 10
1 1 2 4 1 1 16
36864 16 4032 16257024 96 384 227524445
0 1 1 1 0 1 1
244858606 337827833 584144609 343808937 412777304 279017446 926699892