School Colors
Time limit1sMemory limit128 MB
Given up to 200 RGB colors, find every pair whose Euclidean distance is maximal and print the index pairs in sorted order.
- Level
Easy3 of 10
- Topics
- Brute force, Geometry, Implementation, Math
- Solved
- No attempts yet
Problem
You already know a university's school colors, right? They may not be the prettiest combination, but at least each one is legible written on top of the other — much better than, say, Cardinal and Red, or Green and Turquoise. One imagines that universities make some effort to pick contrasting colors. But did they pick the most contrasting ones?
In this problem you will write a program that finds the most contrasting pair of colors in a given list. Each color is specified by a triple denoting its red, green, and blue values, where each value is an integer between 0 and 255. The triple is Black and is White. The contrast between two colors is the Euclidean distance between their triples: for and it is .
Hint: think Cardinal and Gold.
Input
The first line contains an integer , the number of data sets. It is followed by data sets of the following form.
The first line of a data set contains an integer (), the number of colors in the data set. It is followed by lines, each containing three integers , , () — the red, green, and blue values of the -th color in the list.
Output
For each data set, first output a line “Data Set x:” by itself, where is the data set's number (starting from 1). Then output the pair of colors with the largest possible contrast, given as two 1-based indices per line. If several pairs achieve the largest contrast, output all of them, sorted by increasing first index, breaking ties by increasing second index.