[UVA] 1237 - Expert Enough?@Morris' Blog|PChome Online 人新台
2012-09-02 12:17:05| 人2,037| 回2 | 上一篇 | 下一篇

[UVA] 1237 - Expert Enough?

0 收藏 0 0 站台

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

The program receives a price P as an input, and searches through the database for a car maker in which P falls in their range of lowest price L and highest price H of car they ever made. The program then output the car maker name. If the database contains no or more than one car maker that satisfies the query, the program produce output ``UNDETERMINED" (without quotes). Not so expert, huh? You are about to develop that program for ACM.

Input 

The input begins with a line containing an integer T (T$ le$10) , the number of test cases follow. Each case begins with the size of the database D (D < 10000) . The next each of D lines contains M , L and H (0 < L < H < 1000000) which are the name of the maker (contains no whitespace and will never exceeds 20 characters), the car's lowest price the maker ever made, and the car's highest price the maker ever made respectively. Then there is the number of query Q (Q < 1000) . follows. Each of the next Q lines contains an integer P (0 < P < 1000000) , the query price.

Output 

Output for each query should be one line containing the name of the maker, or the string ``UNDETERMINED" (without quotes) if there is no maker or more than one maker that satisfies the query. You should separate output for different case by one empty line.

Sample Input 

1 4 HONDA 10000 45000 PEUGEOT 12000 44000 BMW 30000 75900 CHEVROLET 7000 37000 4 60000 7500 5000 10000 

Sample Output 

BMW CHEVROLET UNDETERMINED UNDETERMINED


#include <stdio.h>

int main() {
int t;
scanf("%d", &t);
while(t--) {
int n, m, p;
int l[10000], h[10000];
int i;
char name[10000][25];
scanf("%d", &n);
for(i = 0; i < n; i++)
scanf("%s %d %d", name[i], &l[i], &h[i]);
scanf("%d", &m);
while(m--) {
scanf("%d", &p);
int cnt = 0, mi;
for(i = 0; i < n; i++) {
if(l[i] <= p && p <= h[i])
cnt++, mi = i;
if(cnt > 1) break;
}
if(cnt == 1)
puts(name[mi]);
else
puts("UNDETERMINED");
}
if(t)
puts("");
}
return 0;
}
 

台: Morris
人(2,037) | 回(2)| 推 (0)| 收藏 (0)|
全站分: 不分 | 人分: UVA |
此分下一篇:[UVA] 927 - Integer Sequences from Addition of Terms
此分上一篇:[UVA] 10365 - Blocks

(悄悄)
2025-10-06 19:38:21
seo
Fantastic Put up, I'm sure a giant believer through post feed-back concerning webpages towards allow the blog page consultants recognise that theyve further a specific thing positive towards the web! IPTV GERMAN http://beste-iptv.de/
2025-10-07 22:32:33
是 (若未登入"人新台"看不到回覆唷!)
* 入:
入片中算式的果(可能0) 
(有*必填)
TOP
全文
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86