Logo
(追記) (追記ここまで)

9760번 - Search Suggestion 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB777510.000%

문제

A hotel booking website would like to add search suggestion feature on their website. This suggestion will be used to help customers searching for hotels in a particular city. Typically, users would type a prefix of a city name and the search would suggest the three most popular city names that match with that prefix. Since this website needs to process millions of search queries per day, a limit has been placed to reduce the server workload. The search suggestion feature will be activated only if the search query matches no greater than one thousand city names. Your assignment is to create the search suggestion feature for this booking website.

입력

The first part of the input is city data. The first line is the number of cities (N where 1 ≤ N ≤ 500,000) following by pairs of data consisting of city name and its popularity score (S where 1 ≤ S ≤ 100), which is separated by a comma (“,”). The city data is sorted in ascending order by city name. The second part of the input is query data. Similarly, the first line is the number of queries (Q where 1 ≤ Q ≤ 300,000) following by a list of queries which is a string.

출력

For each query, output the query and its corresponding search suggestions. The query could result in 3 types of result, which are:

  1. If the city names that match with the query are less than or equal to one thousand the result will show suggested city names (maximum 3 city names) with its popularity score (separated by a comma).
  2. If the city names that match with the query are greater than one thousand, the result will show only the total number of city that match with that query (plain number without any text or decimal mark).
  3. If there is no city name that matches with the query, the result will show a text “N/A”.

In case that the popularity score of cities that match with the query are equal, the result must shows in the ascending order of city name.

제한

예제 입력 1

7
BANGKOK,71
BEIJING,72
LOMBARDY,65
LONDON,78
LOS ANGELES,80
LOUVRE,65
ZURICH,70
4
Ban
London
Lo
y

예제 출력 1

Ban
BANGKOK,71
London
LONDON,78
Lo
LOS ANGELES,80
LONDON,78
LOMBARDY,65
y
N/A

노트

Please note that the system is case-insensitive.

출처

ICPC > Regionals > Asia Pacific > Thailand > Thailand Central Group-B Programming Contest > Thailand Central Group-B Programming Contest 2013 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /