连接:Print Check

题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果。

从数据的大小看,暴力肯定要TLE;

问题是如何存储数据。

首先:我们只要最后的涂色结果。

其次:没有必要用for每个数据涂一遍。

所以如果能一次直接涂一行就可以了;

#include <iostream>
#include <cstdio>
uising namespace std;
#define N 5005
const int M = 1e9 +;
typedef long long LL;
int row[N],col[N];
int rt[N],ct[N];
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n,m,k,x,a,rc;
cin>>n>>m>>k;
for(int i = ; i <= k; i++){
scanf("%d%d%d",&rc,&x,&a);
if(rc == ){
row[x] = a;rt[x] = i;
}
else {
col[x] = a;ct[x] = i;
}
}
for(int i = ;i <= n; i++){
for(int j = ;j <= m;j++){
printf("%d ",rt[i] < ct[j]?col[j]:row[i]);
}
printf("\n");
}
return ;
}

存储构造题(Print Check)的更多相关文章

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

  2. HDU 5355 Cake (WA后AC代码,具体解析,构造题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others) ...

  3. cf251.2.C (构造题的技巧)

    C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...

  4. Educational Codeforces Round 7 D. Optimal Number Permutation 构造题

    D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...

  5. 【构造题 贪心】cf1041E. Tree Reconstruction

    比赛时候还是太慢了……要是能做快点就能上分了 Monocarp has drawn a tree (an undirected connected acyclic graph) and then ha ...

  6. Codeforces 1491G - Switch and Flip(构造题)

    Codeforces 题目传送门 & 洛谷题目传送门 obviously,难度高一点的构造题对我来说都是不可做题 首先考虑将排列拆成一个个置换环,也就是 \(\forall i\) 连边 \( ...

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

  8. hdu4671 Backup Plan ——构造题

    link:http://acm.hdu.edu.cn/showproblem.php?pid=4671 其实是不难的那种构造题,先排第一列,第二列从后往前选. #include <iostrea ...

  9. Codeforces 482 - Diverse Permutation 构造题

    这是一道蛮基础的构造题. - k         +(k - 1)      -(k - 2) 1 + k ,    1 ,         k ,             2,    ....... ...

随机推荐

  1. tony_nginx_02_URL重写

    location正则写法 一个示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } location / { # 因为所有的 ...

  2. 66. Regular Expression Matching

    Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...

  3. Flex加载google地图、百度地图以及天地图作底图

    一  Flex加载Google地图作底图 (1)帮助类GoogleLayer.as /* * 根据输入的地图类型加载Google地图(by chenyuming) */ package Layers ...

  4. 2016-06-06:X264码率控制

    H.264与x264 H264是一个视频压缩编码标准.https://zh.wikipedia.org/wiki/H.264/MPEG-4_AVC X264实现H264视频压缩标准的开源项目.http ...

  5. Linux VM acquisition

    The evidence is a VM as below. The flat vmdk is the real disk, and the vmdk only 1kb is just a descr ...

  6. teamviewer现在无法捕捉屏幕,这可能是由于快速的用户切换或远程桌面会话已经断开

    解决方法:      不用远程连接过去开启teamview,直接在在电脑本机上手动开启teamview就可以了 即:如果是mstsc远程过去开启,则会有这个错误提示,需要让服务器连接显示器,手动去登录 ...

  7. nginx_tomcat负载均衡环境

    Nginx+Tomcat搭建 版本 操作系统版本 Centos 6.4 Nginx版本 nginx-1.3.15.tar.gz JDK版本 jdk-7u71-linux-i586 //jdk1.7 T ...

  8. Java基础以及与C++的一些对比

    这两天回忆一些Java基础,感觉自己很多地方都不是很牢固,也花费在不少时间和不少流量在手机上查资料. 还是写下来这些东西以免再忘记. 同时还是要记住多动手,编程最重要的就是动手敲啊,有想法有疑问就要自 ...

  9. innobackupex的安装

    innobackupex的安装方法有3种: 通过RPM包安装: 通过源码包安装: 通过二进制包安装. 第3种方法最简单,这里只介绍它.以下是安装步骤: 打开官方下载链接: Version默认是最新版本 ...

  10. java笔记1

    第五天学习笔记 1.面对对象的理解并举例? 面对对象的核心:找合适的对象做合适的事情. 面对对象编程的思想:尽可能的用计算机语言来描述现实生活中的事物. 面对对象:侧重于对象 2.类与对象之间的关系? ...