题意:

按顺序给定列和行进行涂色,输出最终得到的方格颜色分布。

分析:

记录下涂的次序,如果某个元素的横和列都被涂过,那么就选择次序最大的颜色。

代码:

#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【模拟】的更多相关文章

  1. Codeforces 631B Print Check (思维)

    题目链接 Print Check 注意到行数加列数最大值只有几千,那么有效的操作数只有几千,那么把这些有效的操作求出来依次模拟就可以了. #include <bits/stdc++.h> ...

  2. CodeForces 631B Print Check

    对于每一个格子,看是行最后画还是列最后画.预处理一下就可以了. #include<stdio.h> #include<string.h> int n,m,k; +]; +]; ...

  3. CodeForces 631C Print Check

    排序+构造+预处理 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm ...

  4. codeforces 631B B. Print Check

    B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 存储构造题(Print Check)

    连接:Print Check 题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果. 从数据的大小看,暴力肯定要TLE: 问题是如何存储数据. 首先:我们只要最后的涂色结果. 其次: ...

  9. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

随机推荐

  1. NSoup获取网页源代码

    NSoup是JSoup的Net移植版本.使用方法基本一致. 如果项目涉及HTML的处理,强烈推荐NSoup,毕竟字符串截断太苦逼了. 下载地址:http://nsoup.codeplex.com/ # ...

  2. Windows10系统切换JDK版本(前提是装了多个版本的JDK)

    由于是直接截屏,等我回过头来整理的时候忘记了文章原来的出处, 如作者本人看到,如有侵权,请联系删除!

  3. [BZOJ1061][Noi2008]志愿者招募 线性规划+费用流

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1061 根据题意列方程,然后用网络流解线性规划. 题解直接贴ByVoid的吧,太神了:htt ...

  4. MYSQL 查询方法 统计查询 链接查询 子查询

    mysql表格查询方法: 查询: 1.简单查询 select * from Info --查所有数据select Code,Name from Info --查指定列的数据select Code as ...

  5. [转]c++应用程序文件的编译过程

    原文地址 这里讲下C++文件的编译过程及其中模板的编译过程: 一:一般的C++应用程序的编译过程.    一般说来,C++应用程序的编译过程分为三个阶段.模板也是一样的. 在cpp文件中展开inclu ...

  6. (转)Nutz | Nutz项目整合Spring实战

    http://blog.csdn.net/evan_leung/article/details/54767143 Nutz项目整合Spring实战 前言 Github地址 背景 实现步骤 加入spri ...

  7. Python之三元运算、集合、函数

    一.三元运算符 三元运算符就是在赋值变量的时候,可以直接加判断,然后赋值 格式:[on_true] if [expression] else [on_false] res = 值1 if 条件 els ...

  8. CHECKPOINT - 强制一个事务日志检查点

    SYNOPSIS CHECKPOINT DESCRIPTION 描述 预写式日志(Write-Ahead Logging (WAL))缺省时在事务日志中每隔一段时间放一个检查点. (要调整这个原子化的 ...

  9. lua 之 三木运算符

    在c语言中我三目运算符这么写: a?b:c 例如: max = a>b?a:b; 在lua中我们这么写 max = a>b and a or b 运行如下:

  10. 卸载钩子 UnhookWindowsHookEx

    The UnhookWindowsHookEx function removes a hook procedure installed in a hook chain by the SetWindow ...