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 ...
随机推荐
- oracle数据库常用的99条查询语句
1. select * from emp; 2. select empno, ename, job from emp; 3. select empno 编号, ename 姓名, job 工作 fro ...
- mybatis的mapper.xml文件细节
- AJPFX关于代码块的总结
代码块: { 执行语句; }(1) 当出现在局部位置时, 为局部代码块. 局部位置: 如语句块中, 函数中, 构造代码块中, 静 ...
- 构建微服务开发环境5————安装Node.js
[内容指引] 下载Node.js: Mac下安装Node.js: Windows下安装Node.js; 查看node和npm的版本. 一.下载Node.js 访问Node.js官网:https://n ...
- SpringMvc如何将Url 映射到 RequestMapping (二)
昨天简单分析了Springmvc 中 RequestMapping 配置的url和请求url之间的匹配规则.今天详细的跟踪一下一个请求url如何映射到Controller的对应方法上 一.入口 org ...
- ES6学习笔记(2)----变量的解构和赋值
参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ 变量的解构和赋值 本质上:只要模式匹配,左边的变量就能被赋予右边对应的值 原则: 解构赋值的规则 ...
- Rxlifecycle使用详解,解决RxJava内存泄露问题
http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/1122/3711.html
- Nodejs AES加密不一致问题的解决
最近在做android游戏,客户端与Nodejs服务端数据的交互用AES进行加密,发现Nodejs与java的加密形式不一样.查询N久资料发现java端需要对密钥再MD5加密一遍(我了个大擦),本来对 ...
- [Windows Server 2008] IIS配置伪静态方法(Web.config模式的IIS rewrite)
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:安装伪静态(w ...
- Net作业调度
Net作业调度(一) -Quartz.Net入门 2014-11-01 13:14 by 蘑菇先生, 13954 阅读, 7 评论, 收藏, 编辑 背景 很多时候,项目需要在不同时刻,执行一个或很多个 ...