2016 Al-Baath University Training Camp Contest-1 D
Description
X is well known artist, no one knows the secrete behind the beautiful paintings of X except his friend Y, well the reason that Y knows X's secrete is that he is that secret. Y is a programmer and he helps X with drawing paintings using computer program written by him. Unfortunately Y program is not working any more, now it's your turn to help X by writing a program that helps him in painting, your program should accept a sequence of instructions, each will draw an opaque (filled) rectangle in the form: r1, c1, r2, c2, color. where (r1, c1) is the upper left corner of the rectangle and (r2, c2) is the lower right corner, and color is a character that denotes the color of this rectangle. all rectangles will be printed on a R by C plane, by default this plane is filled with dots (i.e. '.'). R and C between 1 and 100. for each instruction (1 ≤ ri ≤ R) and (1 ≤ ci ≤ C) and color is a ASCII character [a-z]. The number of instructions won't exceed 100 instructions.
The first line of input contains an integer T denotes number of test cases. The first line of each test case contains three integers R, C ,Iwhere R and C denotes number of rows and columns of the painting, and I denotes number of instructions. Each of the next I lines contains four integers r1,c1,r2,c2 and the color character.
Print the final plane after evaluating the instructions in order.
1
5 5 3
1 1 2 2 a
1 2 5 5 c
2 2 3 3 d
acccc
addcc
.ddcc
.cccc
.cccc
题意:从x1,y1画到x2,y2,颜色为c,问我们最后画出来的颜色分布
解法:暴力,原先画的颜色会被后面的覆盖
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char a[105][105];
int T;
cin>>T;
while(T--){
int c,r,m,b[4];
cin>>r>>c>>m;
for(int i=1;i<=r;i++){
for(int k=1;k<=c;k++){
a[i][k]='.';
}
}
while(m--){
char ch;
for(int i=0;i<4;i++){
cin>>b[i];
}
cin>>ch;
for(int i=b[0];i<=b[2];i++){
for(int k=b[1];k<=b[3];k++){
a[i][k]=ch;
}
}
}
for(int i=1;i<=r;i++){
for(int k=1;k<=c;k++){
cout<<a[i][k];
}
cout<<endl;
}
}
return 0;
}
2016 Al-Baath University Training Camp Contest-1 D的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)
2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) Problem A. M ...
- 2016 Al-Baath University Training Camp Contest-1 E
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...
- 2016 Al-Baath University Training Camp Contest-1 B
Description A group of junior programmers are attending an advanced programming camp, where they lea ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 2016 Al-Baath University Training Camp Contest-1 J
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...
- 2016 Al-Baath University Training Camp Contest-1 I
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...
- 2016 Al-Baath University Training Camp Contest-1 H
Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...
- 2016 Al-Baath University Training Camp Contest-1 G
Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...
- 2016 Al-Baath University Training Camp Contest-1 F
Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...
随机推荐
- DataFrame使用mysql数据
错误提示: Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc ...
- java mybatis XML文件中大于号小于号转义
因为这个是xml文件不允许出现类似“>”这样的字符 用了转义字符把>和<替换掉,然后就没有问题了. <= 相当于 <= >= 相当于 >= XML转义字 ...
- Mysql索引总结(二)
在数据库表中,对字段建立索引可以大大提高查询速度.假如我们创建了一个 mytable表: ) NOT NULL ); 在查找username="admin"的记录 SELECT * ...
- 夺命雷公狗---node.js---19之项目的构建在node+express+mongo的博客项目4mongodb在项目中的基本引入
首先我们在命令行下先建立这个库: 然后我们在项目中引入mongodb的模块: var MongoClient = require('mongodb').MongoClient; var DB_STR ...
- 搞不定linux下的无线网卡驱动的权宜之计
毕竟windows用了这么些年了,对windows下的一些东西也比较熟悉,还有就是windows的软件方式比较傻瓜. 在linux下搞不定无线网卡啊,幸亏有甲骨文的virtualbox,咱虚拟一个xp ...
- 由linux下的多进程编程引发的关于进程间隔离的思考
源代码放到了三个文件中: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include & ...
- 安装交叉编译器arm-linux-gcc
需要交叉编译环境故安装交叉编译环境 1.在宿主机的/usr/local/arm目录存放交叉编译器 mkdir /usr/local/arm 2.解压交叉编译器包至/usr/l ...
- IOC依赖注入简单实例
转自:http://hi.baidu.com/xyz136299110/item/a32be4269e9d0c55c38d59e6 相信大家看过相当多的IOC依赖注入的例子. 但大家在没有明白原理的情 ...
- 鸟哥的linux私房菜学习记录之档案与目录管理
绝对路径和相对路径 绝对路径就是从根目录到某个目录下的路径,从根目录写起,也就是/ 相对路径就是从用户当前目录的路径写起 目录相关操作 cd 切换路径 例如:cd /var/www 切换到/var/w ...
- 记一个由MemCached引发的性能问题
最近有个项目用loadrunner做了压力测试,发现并发量还不到200服务器就支撑不住了.boss那边紧急开会,说此项目最近3个月内将有100家中大型公司用于校园招聘工作,如果这个问题不解决公司有可能 ...