Programming contests

ECN selejtező programozó csapatverseny, 2015. április 19.

April 19, 2015 10:10 AM – April 19, 2015 3:10 PM

Expert Enough?

Automobile Charting & Manufacturing (ACM) is a company that specializes in manufacturing automobile spare parts. Being one of the leading automotive companies in the world, ACM is sure to keep up with the latest information in that world. In the 100-year anniversary of the company, ACM compiled a huge list of ranges of prices of any automobiles ever recorded in the history. ACM then wants to develop a program that they call Automobile Expert System or AES for short.

The program receives a price P as input and searches through the database for a car maker such that P falls in the range from the lowest price L to the highest price H of any cars they have ever made. The program then outputs the name of the car maker. If the database contains no or more than one car maker that satisfies the query, the program produces the output “UNDETERMINED”. Not so expert, huh? You are about to develop that program for ACM.

Input Specification

The input begins with a line containing an integer T (T ≤ 10), the number of test cases that follow. Each case begins with the size of the database D (D < 10 000). Each of the next D lines contains M, L, and H (0 < L < H < 1 000 000), which are the name of the car maker (containing no whitespaces and never exceeding 20 characters), the lowest price of any cars the car maker has ever made, and the highest price of any cars the car maker has ever made, respectively. Then there is the number of queries Q that follow (Q < 1000). Each of the next Q lines contains an integer P (0 < P < 1 000 000), the query price.

Output Specification

Output for each query should be one line containing the name of the car maker, or the string “UNDETERMINED” (without quotes) if there is no car maker or more than one car maker that satisfies the query. You should separate the outputs for two consecutive cases with an empty line.

Sample Input

  1. 1
  2. 4
  3. HONDA 10000 45000
  4. PEUGEOT 12000 44000
  5. BMW 30000 75900
  6. CHEVROLET 7000 37000
  7. 4
  8. 60000
  9. 7500
  10. 5000
  11. 10000
download as text file

Output for Sample Input

  1. BMW
  2. CHEVROLET
  3. UNDETERMINED
  4. UNDETERMINED
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019