# 1046 poj Color Me Less

把后输入的数据与前16个数据进行匹配，如果他们之间的距离在所有数据匹配中最小

就输出

/*
Sample Input

0 0 0
255 255 255
0 0 1
1 1 1
128 0 0
0 128 0
128 128 0
0 0 128
126 168 9
35 86 34
133 41 193
128 0 128
0 128 128
128 128 128
255 0 0
0 1 0
0 0 0
255 255 255
253 254 255
77 79 134
81 218 0
-1 -1 -1

Sample Output

(0,0,0) maps to (0,0,0)
(255,255,255) maps to (255,255,255)
(253,254,255) maps to (255,255,255)
(77,79,134) maps to (128,128,128)
(81,218,0) maps to (126,168,9)

*/
#include<stdio.h>
#define INF 0xfffffff

struct Node
{
int x,y,z;
}target[1000],mapp[1000],Rem[1000];

int distance(Node a,Node b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);
}

int main()
{
int i,j;
for (i=1;i<=16;i++)
scanf("%d%d%d",&target[i].x,&target[i].y,&target[i].z);
int cas=1;
while(1)
{
scanf("%d%d%d",&mapp[cas].x,&mapp[cas].y,&mapp[cas].z);
if(mapp[cas].x==-1 && mapp[cas].y==-1 && mapp[cas].z==-1) break;
cas++;
}
int dis,k;
for (i=1;i<cas;i++)
{
dis=INF;
for (j=1;j<=16;j++)
{
if(target[j].x==-1) continue;
if(dis>distance(mapp[i],target[j]))
{
dis=distance(mapp[i],target[j]);
k=j;
}
}
Rem[i]=target[k];
target[j].x=-1;//If there are more than one color with the same smallest distance
}
for (i=1;i<cas;i++)
printf("(%d,%d,%d) maps to (%d,%d,%d)\n",mapp[i].x,mapp[i].y,mapp[i].z,
Rem[i].x,Rem[i].y,Rem[i].z);
//system("pause");
return 0;
}

• 本文已收录于以下专栏：

## poj 1046(Color Me Less)

Color Me Less Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23677   ...

## Color Me Less POJ - 1046

A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this ...

## POJ 1046-Color Me Less【暴力】

A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this ...

## POJ1046——Color Me Less

Color Me Less Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 33605   ...

## POJ 1046 Color Me Less

Color Me Less Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31449   Accepted: 1...

## POJ1046 Color Me Less(水题就当玩吧)

Color Me Less Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31681   ...

## <poj 1046>Color Me Less

Color Me Less   Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25873 ...

## 1046 Color Me Less

Description A color reduction is a mapping from a set of discrete colors to a smaller one. The so...

## AOJ-AHU-OJ-186 Color Me Less

Color Me Less Time Limit: 1000 ms   Case Time Limit: 1000 ms   Memory Limit: 64 MB Descr...

## zoj 1067 Color Me Less

Color Me Less Time Limit: 2 Seconds      Memory Limit: 65536 KB Problem A color reduction i...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)