Tuesday, 19 January 2016

Color Me Less (UVALive 2281, ZOJ 1067, POJ 1046, Regionals 2001 >> North America - Greater NY)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100000


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1, n, arr[20][5], r, g, b;
    for(int i=0;i<16;i++)
    {
        for(int j=0;j<3;j++)
            cin>>arr[i][j];
    }
    while(cin>>r>>g>>b)
    {
        if(r<0) break;
        int mn=1e9;
        int id=-1;
        for(int i=0;i<16;i++)
        {
            int tmp = ((r-arr[i][0])*(r-arr[i][0]) + (g-arr[i][1])*(g-arr[i][1]) + (b-arr[i][2])*(b-arr[i][2]));
            //tmp = sqrt(tmp);
            if(tmp<mn)
            {
                mn=tmp;
                id=i;
            }
        }
        cout<<"("<<r<<","<<g<<","<<b<<") maps to ("<<arr[id][0]<<","<<arr[id][1]<<","<<arr[id][2]<<")\n";
    }
return 0;
}

No comments:

Post a Comment