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 ...
随机推荐
- R in action读书笔记(12)第九章 方差分析
第九章方差分析 9.2 ANOVA 模型拟合 9.2.1 aov()函数 aov(formula, data = NULL, projections =FALSE, qr = TRUE, contra ...
- linux centos 下php的mcrypt扩展
去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 libmcrypt(libmcrypt-2.5.8.tar.gz ):mcrypt(mcr ...
- 【Lucene】实现全文索引
2. Lucene 实现全文检索的流程2.1.索引和搜索流程图 绿色表示索引过程,对要搜索的原始内容进行索引构建一个索引库,索引过程包括:确定原始内容即要搜索的内容 -> 采集文档 -> ...
- shellinabox的安装使用
一.简介 Shell In A Box(发音是shellinabox)是一款基于Web的终端模仿器,由Markus Gutschke开辟而成.它有内置的Web办事器,在指定的端口上作为一个基于Web的 ...
- 解决docker pull镜像速度慢的问题
直接下载Docker镜像时,由于种种原因,经常下载失败,即使连接成功也是很慢,怎么办呢 目前我知道可以提升速度的办法:DaoCloud 提供Docker Hub Mirror服务 用户可以进入Dock ...
- ubuntu18.04 frpc安装与自动启动
1. 下载, 解压 export FRP_VERSION='0.25.3' wget --no-check-certificate https://github.com/fatedier/frp/re ...
- element-UI el-table表格根据搜索条件表格值改变颜色
Part.1 关键代码 var s = "天气"; // 需要匹配的字符 var reg = new RegExp("(" + s + ")" ...
- 02Hibernate基本配置
Hibernate基本配置 1.引入jar 2.建立项目 3.创建实体类 package com.sqlserver.domain; public class Customer { long cust ...
- redis中基本命令
记录一下redis中的基本命令.redis中有redis-cli工具客户端,使用这个客户端来发送一些命令 一.redis-cli的使用 1.redis-cli使用之发送命令 2.redis-cli使 ...
- oracle获取排序后的第一条信息
查询表table1里字段id小于10的所有数据,并且让数据根据id降序排列,然后得到第一条数据 select * from (select * from table1 where id<10 o ...