位图像素的颜色
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
有一个在位图上画出矩形程序,一开始位图都被初始化为白色(RGB颜色表示为R=G=B=255)。该程序能够按照顺序绘出N个矩形。新绘制的矩形能够覆盖位图上原有的颜色。程序执行完毕后,需要查询M个点的颜色,输出这些点的RGB值。 每组数据都是在初始化后开始绘制。
Input
第一行包含参数N和M,分别表示矩形个数和需要查询的像素个数(1 ≤N, M≤ 1000 ); 剩下N行每行包含7个参数x1, y1, x2, y2, r, g, b,表示绘制一个(x1,y1),(x2,y2)为顶点的矩形,填充颜色为RGB(r, g, b),其中x1≤x2, y1≤y2数据在整型范围;0≤ r,g,b ≤ 255; 最后M行分别包含参数X和Y,表示需要查询的像素位置。 如果某行N=M=0就表示输入结束。
Output
对于每个用例,按行输出查询的像素的RGB值,每行包含3个整数,分别表示RGB值。
Sample Input
1 2 0 0 2 3 127 196 200 1 2 3 0 2 3 8 16 32 64 0 255 128 8 48 32 64 255 0 0 12 47 13 48 14 64 0 0
Sample Output
127 196 200 255 255 255 0 255 128 255 0 0 255 0 0
我也不知道能不能ac呀,我以为9点半结束呢= =没来得及交耶。。。
ac了,hdu把比赛题目放上来了,忽略昨天的碎碎念吧~链接:
http://acm.hdu.edu.cn/diy/contest_show.php?cid=23037
思路就是倒序遍历那些矩形,在里面就输出,结束遍历;不在里面就继续往前,要是遍历完了还是木有合适的矩形,就输出白色啦。。。
哎呀哎呀烦死啦,我怎么会以为9点半结束呢呜呜,虽然肯定没戏,但是就想知道能不能a呀= =讨厌!
哼╭(╯^╰)╮
总结经验:动手之前先把所有题目过一遍,简单的有把握的就先搞定~但是但是第一题那个“石头剪子布”我也不知道哪里错了就wa了耶,这些oj平台敢不敢把出错的数据反馈一下呀!!!比赛完再反馈也可以呀╭(╯^╰)╮
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <vector>
using namespace std;
const int MAXSIZE = 10010;
struct kk{
int x1, y1;
int x2, y2;
int r, g, b;
};
class B{
private:
int N, M;
kk ee[MAXSIZE];
public:
void initialize(int, int);
void readCase();
void computing();
void outResult();
};
void B::initialize(int n, int m){
N = n, M = m;
}
void B::readCase(){
int x11, y11, x22, y22, rr, gg, bb;
for(int i = 0; i<N; i++){
cin>>x11>>y11>>x22>>y22>>rr>>gg>>bb;
ee[i].x1 = x11;
ee[i].y1 = y11;
ee[i].x2 = x22;
ee[i].y2 = y22;
ee[i].r = rr;
ee[i].g = gg;
ee[i].b = bb;
}
}
void B::computing(){
for(int i = 0; i<M; i++){
int x, y;
cin>>x>>y;
int flag = 0;
for(int j = N-1; j>=0; j--){
if(x>=ee[j].x1 && x<=ee[j].x2 && y>=ee[j].y1 && y<=ee[j].y2){
cout<<ee[j].r<<" "<<ee[j].g<<" "<<ee[j].b<<endl;
flag = 1;
break;
}
}
if(flag == 0){
cout <<"255 255 255"<<endl;
}
}
}
void B::outResult(){
}
int main(){
int n, m;
while(cin>>n>>m){
if(n == 0 && m == 0){
return 0;
}
B b;
b.initialize(n, m);
b.readCase();
b.computing();
b.outResult();
}
return 0;
}