2016 Al-Baath University Training Camp Contest-1 D

时间:2022-04-03 06:43:07

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.

Input

The first line of input contains an integer T denotes number of test cases. The first line of each test case contains three integers RC ,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.

Output

Print the final plane after evaluating the instructions in order.

Example
input
1
5 5 3
1 1 2 2 a
1 2 5 5 c
2 2 3 3 d
output
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;
}