CF631B.Print Check

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to tests it. He wants you to implement the program that checks the result of the printing.

Printer works with a rectangular sheet of paper of size n × m. Consider the list as a table consisting of n rows and m columns. Rows are numbered from top to bottom with integers from 1 to n, while columns are numbered from left to right with integers from 1 to m. Initially, all cells are painted in color 0.

Your program has to support two operations:

  1. Paint all cells in row r__i in color a__i;
  2. Paint all cells in column c__i in color a__i.

If during some operation i there is a cell that have already been painted, the color of this cell also changes to a__i.

Your program has to print the resulting table after k operation.

Kris 就职于一家大型公司“Blake Technologies”。作为公司最优秀的工程师,他被委派开发一款能够打印水平和垂直条带的打印机。首个原型机已经建成,Kris 希望对其进行测试。他希望你编写一个程序来验证打印结果。

该打印机使用一张大小为 n×mn \times m 的矩形纸张。将这张纸视为一个由 nn 行和 mm 列组成的表格。行从上到下依次编号为 11 至 nn,列从左到右依次编号为 11 至 mm。初始时,所有格子的颜色均为 00。

你的程序需支持以下两种操作:

  1. 将第 rir_i 行的所有格子涂成颜色 aia_i;
  2. 将第 cic_i 列的所有格子涂成颜色 aia_i。

若在某次操作 ii 中,某个格子此前已被涂色,则其颜色也更新为 aia_i。

你的程序需输出经过 kk 次操作后的最终表格。

输入格式

The first line of the input contains three integers n, m and k (1  ≤  n,  m  ≤ 5000, n·m ≤ 100 000, 1 ≤ k ≤ 100 000) — the dimensions of the sheet and the number of operations, respectively.

Each of the next k lines contains the description of exactly one query:

  • 1 r__i a__i (1 ≤ r__i ≤ n, 1 ≤ a__i ≤ 109), means that row r__i is painted in color a__i;
  • 2 c__i a__i (1 ≤ c__i ≤ m, 1 ≤ a__i ≤ 109), means that column c__i is painted in color a__i.

输入的第一行包含三个整数 nn、mm 和 kk(1≤n,m≤50001 \le n, m \le 5000,n⋅m≤100 000n \cdot m \le 100\,000,1≤k≤100 0001 \le k \le 100\,000),分别表示纸张的尺寸和操作次数。

接下来的 kk 行,每行描述一个查询:

  • 1 r_i a_i(1≤ri≤n1 \le r_i \le n,1≤ai≤1091 \le a_i \le 10^9),表示将第 rir_i 行涂成颜色 aia_i;
  • 2 c_i a_i(1≤ci≤m1 \le c_i \le m,1≤ai≤1091 \le a_i \le 10^9),表示将第 cic_i 列涂成颜色 aia_i。

输出格式

Print n lines containing m integers each — the resulting table after all operations are applied.

输出 n 行,每行包含 m 个整数——即所有操作执行完毕后的结果表格。

输入输出样例

  • 输入#1

    3 3 3
    1 1 3
    2 2 1
    1 2 2

    输出#1

    3 1 3 
    2 2 2 
    0 1 0
  • 输入#2

    5 3 5
    1 1 1
    1 3 1
    1 5 1
    2 1 1
    2 3 1

    输出#2

    1 1 1 
    1 0 1 
    1 1 1 
    1 0 1 
    1 1 1

说明/提示

The figure below shows all three operations for the first sample step by step. The cells that were painted on the corresponding step are marked gray.

下图逐步展示了第一个样例中的全部三种操作。在对应步骤中被涂色的单元格以灰色标记。

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

首页