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.

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,问我们最后画出来的颜色分布
解法:暴力,原先画的颜色会被后面的覆盖
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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;
}

  

posted @   樱花落舞  阅读(304)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示