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

33639번 - Candy Store 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB88787188.750%

문제

Candy runs, well, a candy store! It is very popular, she has a hard time keeping up with all the orders being placed. She implements a simple system. Each customer who enters the store will fill their order on a form and sign it with their initials.

Maybe she should have asked for their full name instead, since this can sometimes lead to ambiguities about who placed the order. Actually, maybe she should not have let the customers write their own initials because sometimes she might misread them.

At times, Candy needs to consult with the customers about their order. She calls the initials written on the order form. Each time Candy calls out some initials, help her by informing her who the initials corresponds to, or if there are multiple names the initials correspond to, or if nobody has those initials.

입력

The first line of input will contain two integers $N$ (1ドル≤N≤100$) and $Q$ (1ドル≤Q≤100$), denoting the number of customers in the store who have submitted an order and number of initials to query, respectively. The next $N$ lines each contain one name, which is two words separated by a single space. Each of the two words starts with an uppercase letter and is followed by lowercase letters. The length of each word is between 2ドル$ and 10ドル$ characters. No two of the $N$ customers will have the exact same name, though some customers may share the same first name or the same last name.

The next $Q$ lines each contains exactly two uppercase letters describing the initials of a customer Candy wants to talk to.

출력

For each of the $Q$ queries, output one of the following:

  • If there is exactly one name that matches the initials, output the name.
  • If there is no name that matches, output nobody
  • If there is more than one name that matches, output ambiguous

제한

예제 입력 1

4 3
John Doe
Jane Doe
Jimmy Jimmy
Door Jone
JJ
JD
NW

예제 출력 1

Jimmy Jimmy
ambiguous
nobody

힌트

출처

University > University of Alberta Programming Contest > UAPC 2024 > Division 2 I번

  • 문제를 만든 사람: Noah Weninger, Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

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

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