CodingTrip - 휴대용 프로 그래 밍 대회 (예선 2 차 전) 비트 픽 셀 색상
3069 단어 픽 셀 색상
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1299 Accepted Submission(s): 597
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
#include <stdio.h>
#define max 1002
struct Node{
int x1, y1, x2, y2, r, g, b;
} arr[max], temp;
int id, r, g, b;
bool find(int x, int y){
int ok = 0, a, bb, c, d;
for(int i = 0; i < id; ++i){
a = arr[i].x1 < arr[i].x2 ? arr[i].x1 : arr[i].x2;
bb = arr[i].y1 > arr[i].y2 ? arr[i].y1 : arr[i].y2;
c = arr[i].x2 > arr[i].x1 ? arr[i].x2 : arr[i].x1;
d = arr[i].y1 < arr[i].y2 ? arr[i].y1 : arr[i].y2;
if(x >= a && x <= c && y >= d && y <= bb){
r = arr[i].r;
g = arr[i].g;
b = arr[i].b;
ok = 1;
}
}
return ok;
}
int main(){
int n, m;
int x, y;
while(scanf("%d%d", &n, &m), n || m){
id = 0;
while(n--){
scanf("%d%d%d%d%d%d%d", &temp.x1, &temp.y1, &temp.x2,
&temp.y2, &temp.r, &temp.g, &temp.b);
arr[id++] = temp;
}
while(m--){
scanf("%d%d", &x, &y);
if(find(x, y)) printf("%d %d %d
", r, g, b);
else printf("255 255 255
");
}
}
return 0;
}