QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#12019. Sum Transformation

統計

定义矩阵变换 $\mathcal F$,它将一个$n\times n$ 的矩阵 $P$ 变成另一个 $n\times n$ 的矩阵 $Q$:对每个 $1\le i,j\le n$,$Q_{i,j}$ 的值等于矩阵 $P$ 的第 $i$ 行与第 $j$ 列的所有元素的和。

给一个 $n\times n$ 的矩阵 $P$,请计算连续对 $P$ 连续 $t$ 次应用变换 $\mathcal F$ 的结果。请输出结果对 $\mathrm{mod}$ 取模的结果。

输入格式

第一行有3个整数,$n,t,\mathrm{mod}$,分别表示矩阵的大小, $\mathcal F$ 变换的调用次数,以及模数。

接下来 $n$ 行,每行 $n$ 个 $[0,\mathrm{mod}-1]$ 中的整数,表示矩阵的元素。

输出格式

输出 $n$ 行,每行 $n$ 个 $[0,\mathrm{mod}-1]$ 的数字,表示结果。

对所有数据有 $1\le n\le 1000, 0\le t\le 10^9, 2\le \mathrm{mod}\le 10^9$

样例数据

样例 1 输入

3 2 10
1 2 3
4 5 6
7 8 9

样例 1 输出

4 3 2
1 0 9
8 7 6

样例 1 解释

  1. 初始矩阵 $$ \begin{matrix} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{matrix} $$

  2. 一次变换后: $$ \begin{matrix} 8 &1 &4\\ 7 &0 &3\\ 6 &9& 2 \end{matrix} $$

  3. 两次变换后: $$ \begin{matrix} 4 &3& 2\\ 1 &0 &9\\ 8 &7 &6\\ \end{matrix} $$

子任务

子任务一(17分): $n\le 100,t\le 100$.

子任务二(26分): $\mathrm{mod}=2$.

子任务三(57分): $n\le 1000,t\le 10^9,\mathrm{mod}\le 10^9$.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.