CF706E.Working routine

省选/NOI-

通过率:0%

时间限制:2.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasiliy finally got to work, where there is a huge amount of tasks waiting for him. Vasiliy is given a matrix consisting of n rows and m columns and q tasks. Each task is to swap two submatrices of the given matrix.

For each task Vasiliy knows six integers a__i, b__i, c__i, d__i, h__i, w__i, where a__i is the index of the row where the top-left corner of the first rectangle is located, b__i is the index of its column, c__i is the index of the row of the top-left corner of the second rectangle, d__i is the index of its column, h__i is the height of the rectangle and w__i is its width.

It's guaranteed that two rectangles in one query do not overlap and do not touch, that is, no cell belongs to both rectangles, and no two cells belonging to different rectangles share a side. However, rectangles are allowed to share an angle.

Vasiliy wants to know how the matrix will look like after all tasks are performed.

瓦西里终于开始工作了,他面前有大量任务等待完成。瓦西里收到一个由 nn 行 mm 列构成的矩阵,以及 qq 个任务。每个任务要求交换该矩阵中的两个子矩阵。

对于每个任务,瓦西里会得到六个整数 aia_i, bib_i, cic_i, did_i, hih_i, wiw_i,其中 aia_i 是第一个矩形左上角所在行的索引,bib_i 是其所在列的索引,cic_i 是第二个矩形左上角所在行的索引,did_i 是其所在列的索引,hih_i 是矩形的高度,wiw_i 是其宽度。

保证在同一个查询中,两个矩形互不重叠且互不接触,即:没有单元格同时属于两个矩形,且分别属于两个不同矩形的任意两个单元格也不共享一条边。但允许两个矩形仅在顶点处相接(即共享一个角)。

瓦西里想知道,在执行完所有任务后,该矩阵最终的样子。

输入格式

The first line of the input contains three integers n, m and q (2 ≤ n, m ≤ 1000, 1 ≤ q ≤ 10 000) — the number of rows and columns in matrix, and the number of tasks Vasiliy has to perform.

Then follow n lines containing m integers v__i, j (1 ≤ v__i, j ≤ 109) each — initial values of the cells of the matrix.

Each of the following q lines contains six integers a__i, b__i, c__i, d__i, h__i, w__i (1 ≤ a__i, c__i, h__i ≤ n, 1 ≤ b__i, d__i, w__i ≤ m).

输入的第一行包含三个整数 nn、mm 和 qq(2 ≤ n, m ≤ 10002 \le n, m \le 1000,1 ≤ q ≤ 10 0001 \le q \le 10\,000)—— 分别表示矩阵的行数、列数,以及瓦西里需要执行的任务数量。

接下来是 nn 行,每行包含 mm 个整数 vi,jv_{i,j}(1 ≤ vi,j ≤ 1091 \le v_{i,j} \le 10^9)—— 表示矩阵各单元格的初始值。

随后的 qq 行中,每行包含六个整数 aia_i、bib_i、cic_i、did_i、hih_i、wiw_i(1 ≤ ai, ci, hi ≤ n1 \le a_i, c_i, h_i \le n,1 ≤ bi, di, wi ≤ m1 \le b_i, d_i, w_i \le m)。

输出格式

Print n lines containing m integers each — the resulting matrix.

输出 n 行,每行包含 m 个整数——即所得矩阵。

输入输出样例

  • 输入#1

    4 4 2
    1 1 2 2
    1 1 2 2
    3 3 4 4
    3 3 4 4
    1 1 3 3 2 2
    3 1 1 3 2 2

    输出#1

    4 4 3 3
    4 4 3 3
    2 2 1 1
    2 2 1 1
  • 输入#2

    4 2 1
    1 1
    1 1
    2 2
    2 2
    1 1 4 1 1 2

    输出#2

    2 2
    1 1
    2 2
    1 1

输入解题思路,AI测评打分。不知道怎么写?

首页