连接: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. java堆内存和栈内存的处理

    前段时间学习二叉树在处理删除操作的时候遇到一个头疼的问题:删除节点的时候明明已经置null了可树上该节点依旧存在,还必须执行node.father.left = null;才可以删除node节点,寻找 ...

  2. Codeforces Round #226 (Div. 2) B

    B. Bear and Strings time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. ACM好书推荐

    年末感想之(渣渣的我)         仔细想想,搞比赛的日子4年有余了,确实不服老不行了,直到现在平均每天的题量都在3题左右.其实真想说,“渣渣的我”.做的题确实不少了,但是水平还是上不了档次.  ...

  4. winform 控件(1)

    单词:controls(父类),所有的控件dataSource ,工具的数据源DisplayMember,属性,指定的值 <1>label--文本显示工具属性:1.text,是显示文字的n ...

  5. zookeeper节点失效重连机制

    http://www.blogjava.net/xylz/archive/2011/12/05/365578.html http://blog.csdn.net/tswisdom/article/de ...

  6. javascript组件化

    http://purplebamboo.github.io/2015/03/16/javascript-component/#%E5%BC%95%E5%85%A5%E4%BA%8B%E4%BB%B6% ...

  7. socket笔记

    参考: http://www.cnblogs.com/dolphinX/p/3460545.html http://www.cnblogs.com/wei2yi/archive/2011/03/23/ ...

  8. 直接使用docker而无须加sudo

    从0.5.2开始docker的守护进程总是以root用户来运行.docker守护进程绑定的是Unix的socket而不是一个TCP端口.Unix的socket默认属于root用户,所以,使用docke ...

  9. 详解Oracle DELETE和TRUNCATE 的区别(摘)

    语法delete from aa truncate table aa 区别 1.delete from后面可以写条件,truncate不可以. 2.delete from记录是一条条删的,所删除的每行 ...

  10. java多线程学习-同步(synchronized)

    (示例都是网上视频的) 假如两个线程同时调用一个方法输出字符串 public class SynchronizedTest extends Thread { public static void ma ...