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,问我们最后画出来的颜色分布
解法:暴力,原先画的颜色会被后面的覆盖
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; } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 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的设计差异
· 三行代码完成国际化适配,妙~啊~