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

32540번 - Dialling Digits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB77583373.333%

문제

Disaster struck at the Billboards And Phone-numbers Company! % Deliberately using hyphen in Phone-numbers for the backronym Due to a bug in their database system, they lost the corresponding mnemonic phrases for each of the registered phone numbers. These mnemonic phrases are typically used on billboards, to make a phone number for an advertisement easier to remember by people who read them. To dial the phone number from a mnemonic phrase, you simply have to press the number keys corresponding to each letter, as shown in Figure D.1. For example, the phone number "1-800-BAPC" would be dialled as "1-800-2272".

Using this information and a given list of valid words, reconstruct the possible mnemonic phrases for each registered phone number. Each mnemonic phrase consists of exactly one word from the word list. In the input, you will only receive the part of the phone number that should be exactly linked to possible mnemonic phrases, so it does not include the "1-800-" prefix (or any other prefix).

Figure D.1: The keypad of a telephone, where some numbers are assigned several letters.

Public Domain by Sakurambo on Wikimedia Commons, modified

입력

The input consists of:

  • One line with two integers $n$ and $m$ (1ドル \leq n, m \leq 10^5,ドル $n \cdot m \leq 10^5$), the number of words and the number of phone numbers.
  • $n$ lines, each with a word $w$ (1ドル \leq |w| \leq 10$), consisting only of English lowercase letters (a-z). The words are unique and given in alphabetical order.
  • $m$ lines, each with a phone number $p$ (1ドル \leq |p| \leq 10$), consisting only of digits that correspond to letters in a mnemonic phrase (2-9).

출력

For each phone number, output the number of words that are a valid mnemonic phrase for this phone number, followed by these words in alphabetical order.

제한

예제 입력 1

5 3
algorithm
bapc
benelux
contest
progaming
2272
424242
2363589

예제 출력 1

1 bapc
0
1 benelux

예제 입력 2

3 1
peer
reds
refs
7337

예제 출력 2

3 peer reds refs

예제 입력 3

7 3
black
judge
my
of
quartz
sphinx
vow
25225
782789
774466

예제 출력 3

1 black
1 quartz
0

예제 입력 4

5 1
and
bland
e
land
of
63

예제 출력 4

1 of

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2024 Preliminaries D번

  • 문제를 만든 사람: Ragnar Groot Koerkamp
(追記) (追記ここまで)

출처

대학교 대회

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

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