Two Votes, One Package
A busy shipping desk must choose between express and economy, using two clues - weight
(in kilograms) and distance
(in kilometers). Raw distances are dominated by kilometers; after scaling, kilometers and kilograms speak equally. The same parcel can get two different verdicts - and the desk wants to see both.

You are asked to read an initial list of labeled parcels and then, for each new parcel, print two labels: first, the prediction from 3-NN on the raw features, second, the prediction from 3-NN after min-max scaling computed from the initial list only. Use Euclidean distance for neighbor search. If a feature is flat in the initial list, its scaled value is 0 for all rows. If neighbor labels tie, print the alphabetically smallest label.
The first line of the input contains a single integer n
representing how many parcels are in the initial list. Each of the next n
lines contains two floating-point numbers and a label with no spaces - weight distance label
.
The next line contains a single integer q
representing how many new parcels to decide on. Each of the next q
lines contains two floating-point numbers - weight distance
.
The program should print q
lines. Each line should contain two labels, separated by a space: the raw 3-NN decision, followed by the scaled 3-NN decision.
Input | Output |
---|---|
6 | express economy |
8 | express express |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB