存储构造题(Print Check)
连接: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)的更多相关文章
- 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 ...
- HDU 5355 Cake (WA后AC代码,具体解析,构造题)
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others) ...
- cf251.2.C (构造题的技巧)
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...
- Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...
- 【构造题 贪心】cf1041E. Tree Reconstruction
比赛时候还是太慢了……要是能做快点就能上分了 Monocarp has drawn a tree (an undirected connected acyclic graph) and then ha ...
- Codeforces 1491G - Switch and Flip(构造题)
Codeforces 题目传送门 & 洛谷题目传送门 obviously,难度高一点的构造题对我来说都是不可做题 首先考虑将排列拆成一个个置换环,也就是 \(\forall i\) 连边 \( ...
- 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 ...
- hdu4671 Backup Plan ——构造题
link:http://acm.hdu.edu.cn/showproblem.php?pid=4671 其实是不难的那种构造题,先排第一列,第二列从后往前选. #include <iostrea ...
- Codeforces 482 - Diverse Permutation 构造题
这是一道蛮基础的构造题. - k +(k - 1) -(k - 2) 1 + k , 1 , k , 2, ....... ...
随机推荐
- mac安装chromedriver报错
运行提示:Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/c ...
- 慕课网-安卓工程师初养成-6-3 如何使用 Java 中的数组
来源:http://www.imooc.com/code/1525 Java 中操作数组只需要四个步骤: 1. 声明数组 语法: 或者 其中,数组名可以是任意合法的变量名,如: 2. 分配空间 简 ...
- HDOJ2222 Keywords Search-AC自动机
Problem Description In the modern time, Search engine came into the life of everybody like Google, B ...
- js获取浏览器语言(ie、ff、chrome)、contextpath
/js获取浏览器语言(ie.ff.chrome) var language_en_us = "en-us"; var language_zh_cn = "zh-cn&qu ...
- 如何对具有端点加密功能的LINE进行取证
LINE又有新动作了,这回默认即启用了端点加密功能,强调确保传输过程的安全,且让我们来看看如何对付新版的LINE. 有启用Letter Sealing就会在昵称前多个锁头的图像. 这手机据犯嫌供称,落 ...
- 正则表达式python和C++对比
pattern格式(基本通用): pattern格式 符号 说明 ^ 匹配开头 $ 匹配结尾 . 匹配任意一个字符 [...] 匹配任意一个指定的字符 [^...] 匹配任意一个非指定的字符 * 匹配 ...
- MongoEngine简易教程(转)
原文:http://www.xefan.com/archives/84063.html Mongoengine教程(1)——概述 Mongoengine教程(2)——文档模式 Mongoengine教 ...
- html弹出窗并用遮罩层的实例
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- VS2010 "error MSB8011” 解决方法
http://blog.csdn.net/heihei36/article/details/8923971 —————————————————————————————————————————————— ...
- CSS3常用选择器(一)
在 CSS 中,选择器是一种模式,用于选择需要添加样式的元素.比如最常用到的#id,.class,标签选择器. 随着CSS3到来,增加了很多新型选择器,这里就常用的做一个总结. 1.属性选择器. 在c ...