Codeforces 631B Print Check【模拟】
题意:
按顺序给定列和行进行涂色,输出最终得到的方格颜色分布。
分析:
记录下涂的次序,如果某个元素的横和列都被涂过,那么就选择次序最大的颜色。
代码:
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 5005;
int num[maxn][maxn];
int ma[2][maxn];
int ro[maxn], ca[maxn];
int main (void)
{
int n, m, k;cin>>n>>m>>k;
int a, b, c;
for(int i = 1; i <= k; i++){
cin>>a>>b>>c;
if(a == 1){
ro[b] = c;
ma[0][b] = i;
}
else{
ca[b] = c;
ma[1][b] = i;
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
int a = 0;
if(ma[0][i] > ma[1][j]) a = ro[i];
else a = ca[j];
printf("%d%c",a, j == m?'\n':' ');
}
}
}
Codeforces 631B Print Check【模拟】的更多相关文章
- Codeforces 631B Print Check (思维)
题目链接 Print Check 注意到行数加列数最大值只有几千,那么有效的操作数只有几千,那么把这些有效的操作求出来依次模拟就可以了. #include <bits/stdc++.h> ...
- CodeForces 631B Print Check
对于每一个格子,看是行最后画还是列最后画.预处理一下就可以了. #include<stdio.h> #include<string.h> int n,m,k; +]; +]; ...
- CodeForces 631C Print Check
排序+构造+预处理 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm ...
- codeforces 631B 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) 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) 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) 631 B. Print Check (实现)
B. Print Check time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...
- 存储构造题(Print Check)
连接:Print Check 题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果. 从数据的大小看,暴力肯定要TLE: 问题是如何存储数据. 首先:我们只要最后的涂色结果. 其次: ...
- Codeforces 738D. Sea Battle 模拟
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...
随机推荐
- mysql 忘记密码 登陆+修改密码
step1: 苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server) step2: 进入终端输入:cd /usr/local ...
- flex弹性布局操练2
上一个是练习的1个内元素的,这次练习两个元素的. ul.box1 { list-style:none; background-color:black; display:flex; justify-co ...
- Safari兼容之new Date()格式问题
safari浏览器: 故: Safari浏览器应该用‘2017/10/23’来代替‘2017-10-23’ 谷歌浏览器: 谷歌浏览器两种格式都支持
- 说说windows10自带浏览器Edge的好与不好
用了10几个月了,正式版也升级了,今天来说说微软自带浏览器microsoft Edge的好与不好 先说好的吧 一,浏览器速度非常快,无论是打开还是关闭,或者是语音助手小娜需要调动浏 ...
- wifi钓鱼之--Pumpkin
无线钓鱼 前言:请准备一块rt3070的外接网卡 Pumpkin是一款无线安全检测工具WiFi-Pumpkin的使用,利用该工具可以伪造接入点完成中间人攻击,同时也支持一些其它的无线渗透功能.旨在 ...
- RestTemplate接收HashMap变为LinkedHashMap,RestTemplate接收数据后转成json数据出现反斜杠
使用postForObject方法远程调用接口,正常会返回List<HashMap>,然而实际上却返回List<LinkedHashMap>,同时将此数据进行json转换,变成 ...
- No-8.循环
01. 程序的三大流程 在程序开发中,一共有三种流程方式: 顺序 —— 从上向下,顺序执行代码 分支 —— 根据条件判断,决定执行代码的 分支 循环 —— 让 特定代码 重复 执行 02. while ...
- Centos6.8 安装mongo3.6以及权限配置和开启外网链接
目录 安装环境和版本说明,以及参考文档链接 安装MongoDB数据库 运行MongoDB数据库 删除卸载MongoDB 配置MongoDB管理员用户 修改配置文件,允许外网链接 安装配置完成,使用Ro ...
- 从yii2框架中的di容器源码中了解反射的作用
反射简介 参考官方简介的话,PHP 5 具有完整的反射 API,添加了对类.接口.函数.方法和扩展进行反向工程的能力. 此外,反射 API 提供了方法来取出函数.类和方法中的文档注释. YII2框架中 ...
- Redis Hashes 巧用sort排序
假设我们有如下的数据结构: 我们想按download排序,并且返回hash中的其他field,需要怎么处理呢? 我们首先会想到sort命令.对,就是这个sort. 我们先看一下sort的语法: 可以看 ...