303257: CF631B. Print Check
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Print Check
题意翻译
【题目描述】 小澳最近迷上了考古,他发现秦始皇的兵马俑布局十分有特点,热爱钻研的小澳打算在电脑上还原这个伟大的布局。 他努力钻研,发现秦始皇布置兵马俑是有一定规律的。兵马俑阵总共有n行m列,秦始皇在布置的时候每次会指定一行或一列,然后指定一个兵种,使得这一行或者这一列上全部放上这一个兵种。如果这一行上以前放过其它的兵种,那么他会拔掉以前的兵种改成现在他命令的兵种。 小澳从秦朝的文献中找到了布置这个方阵的操作顺序,他希望你能告诉他布局完成后整个兵马俑阵是什么样子的。 【输入格式】 输入文件为matrix.in。 输入文件共q+1行。 输入文件第1行包括三个正整数n,m,q,分别表示兵马俑阵的行数和列数以及秦始皇总的操作数。 接下来q行,每行三个正整数,x,y,z,x表示操作种类,若x=1表示给第y行(y<=n)全部放上z这个兵种,若x=2,则表示给第y列(y<=m)全部放上z这个兵种,数据保证z<=2^31-1。 【输出格式】 输出文件名为matrix.out。 输出文件共n行,每行m个整数,分别用空格隔开。表示最后方阵上每个位置放的兵种,如果某个位置没有被操作过输出0。题目描述
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.输入输出格式
输入格式
The first line of the input contains three integers $ n $ , $ m $ and $ k $ ( $ 1<=n,m<=5000 $ , $ n·m<=100000 $ , $ 1<=k<=100000 $ ) — 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}<=10^{9} $ ), means that row $ r_{i} $ is painted in color $ a_{i} $ ; - $ 2 c_{i} a_{i} $ ( $ 1<=c_{i}<=m $ , $ 1<=a_{i}<=10^{9} $ ), means that column $ c_{i} $ is painted in color $ a_{i} $ .
输出格式
Print $ n $ lines containing $ m $ integers each — the resulting table after all operations are applied.
输入输出样例
输入样例 #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