Codeforces Round #344 (Div. 2) B
1 second
256 megabytes
standard input
standard output
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:
- Paint all cells in row ri in color ai;
- Paint all cells in column ci in color ai.
If during some operation i there is a cell that have already been painted, the color of this cell also changes to ai.
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 ≤ 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 ri ai (1 ≤ ri ≤ n, 1 ≤ ai ≤ 109), means that row ri is painted in color ai;
- 2 ci ai (1 ≤ ci ≤ m, 1 ≤ ai ≤ 109), means that column ci is painted in color ai.
Print n lines containing m integers each — the resulting table after all operations are applied.
3 3 3
1 1 3
2 2 1
1 2 2
3 1 3
2 2 2
0 1 0
5 3 5
1 1 1
1 3 1
1 5 1
2 1 1
2 3 1
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
题意: n*m的矩阵 两种操作 整行变换 与整列变换
1 ri ai (1 ≤ ri ≤ n, 1 ≤ ai ≤ 109), means that row ri is painted in color ai; 整行变为a
2 ci ai (1 ≤ ci ≤ m, 1 ≤ ai ≤ 109), means that column ci is painted in color ai. 整列变为a
输出k次变换后的矩阵;
题解:判断每一个位置上的数 其所在行的变换与所在列的变换的先后顺序以及变换结果 变换在后的 为结果 无变化的输出0;
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
struct node
{
int sor;
int reu;
} a[],b[];
int n,m,k;
int q,w,e;
int main()
{
scanf("%d %d %d",&n,&m,&k);
memset(a,,sizeof(a));
memset(b,,sizeof(b));
for(int i=; i<=k; i++)
{
scanf("%d %d %d",&q,&w,&e);
if(q==)
{
a[w].sor=i;
a[w].reu=e;
}
else
{
b[w].sor=i;
b[w].reu=e;
}
}
for(int i=; i<=n; i++)
{
// cout<<a[i].sor<<" "<<b[i].sor<<endl;
if(a[i].sor>b[].sor)
printf("%d",a[i].reu);
else
{
if(a[i].sor<b[].sor)
printf("%d",b[].reu);
else
printf("");
} for(int j=; j<=m; j++)
{
if(a[i].sor>b[j].sor)
printf(" %d",a[i].reu);
else
{
if(a[i].sor<b[j].sor)
printf(" %d",b[j].reu);
else
printf("");
}
}
printf("\n");
}
return ;
}
Codeforces Round #344 (Div. 2) B的更多相关文章
- Codeforces Round #344 (Div. 2) A. Interview
//http://codeforces.com/contest/631/problem/Apackage codeforces344; import java.io.BufferedReader; i ...
- Codeforces Round #344 (Div. 2) A
A. Interview time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #344 (Div. 2) E. Product Sum 维护凸壳
E. Product Sum 题目连接: http://www.codeforces.com/contest/631/problem/E Description Blake is the boss o ...
- Codeforces Round #344 (Div. 2) D. Messenger kmp
D. Messenger 题目连接: http://www.codeforces.com/contest/631/problem/D Description Each employee of the ...
- Codeforces Round #344 (Div. 2) C. Report 其他
C. Report 题目连接: http://www.codeforces.com/contest/631/problem/C Description Each month Blake gets th ...
- Codeforces Round #344 (Div. 2) B. Print Check 水题
B. Print Check 题目连接: http://www.codeforces.com/contest/631/problem/B Description Kris works in a lar ...
- Codeforces Round #344 (Div. 2) A. Interview 水题
A. Interview 题目连接: http://www.codeforces.com/contest/631/problem/A Description Blake is a CEO of a l ...
- Codeforces Round #344 (Div. 2) B. Print Check
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #344 (Div. 2)(按位或运算)
Blake is a CEO of a large company called "Blake Technologies". He loves his company very m ...
- Codeforces Round #344 (Div. 2)
水 A - Interview 注意是或不是异或 #include <bits/stdc++.h> int a[1005], b[1005]; int main() { int n; sc ...
随机推荐
- 统计hive库表在具体下所有分区大小
1 查询具体表分区大小,以字节展示 hadoop fs -du /user/hive/warehouse/treasury.db/dm_user_excercise > dm_user_exce ...
- 原生js常用方法
原生JavaScript设置cookie值 function setCookie(name, value, Hours) { var d = new Date(); var offset = 8; v ...
- JDK源码分析:Integer.java部分源码解析
1)声明部: public final class Integer extends Number implements Comparable<Integer> extends Number ...
- Android开发-API指南-<supports-screens>
<supports-screens> 英文原文:http://developer.android.com/guide/topics/manifest/supports-screens-el ...
- 从零开始的Python学习Episode 5——字典
字典 字典是另一种可变容器模型,且可存储任意类型对象. 一.添加 (1)直接添加 dict={'name':'smilepup'} dict['age']=20 dict['name']='piggy ...
- Python入门(4)
一.while循环 有时候,你可能需要计算机来帮重复做一件事,这时就需要循环. while condition: statements (else: statements ) 当condition条件 ...
- Entity Framework 基本概念
概念 LINQ to Entities 一种 LINQ 技术,使开发人员可以使用 LINQ 表达式和 LINQ 标准查询运算符,针对实体数据模型 (EDM) 对象上下文创建灵活的强类型化查询. ESQ ...
- appcan打包后产生的问题总结
以appcan为基础的项目,最终需要打包后进行调试.在调试过程中,主要的样式问题在苹果手机上,下面将这些问题总结起来,以防下次再犯. 1:ios 7 以上的手机中,状态栏与内容重叠: 问题描述:在io ...
- TCP系列17—重传—7、SACK下的重传
我们之前介绍SACK选项的时候说过,SACK可以把接收端系列号空间的洞反映给发送端,因此发送端可以更充分的理解接收端的情况,而进行更好的重传恢复过程.这种过程有时候也叫做advanced loss r ...
- loadrunner如何监控windows系统的资源
1.测试客户端与服务器之间的网络,保证通信畅通 2.开启服务器端Windows中的如下两个服务,可见系统服务中查找,cmd输入:services.msc 如下图: Remote Registry需改为 ...