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

25894번 - Phoneme Palindromes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB15811610572.917%

문제

A palindrome is a string that reads the same forward and backward, e.g., madam and abba. Since some letters sound the same (e.g., c and k), we define a phoneme palindrome as a string that sounds the same forward and backward, e.g., cak and ckckbbkcck.

Given the letters that sound the same and a string, you are to determine if the string is a phoneme palindrome.

입력

The first input line contains a positive integer, n, indicating the number of test cases to process. Each test case starts with an integer, p (1 ≤ p ≤ 13), indicating the count for pairs of letters that sound the same. Each of the following p input lines provides two distinct lowercase letters (starting in column 1 and separated by a space) that sound the same. Assume that no letter appears in more than one pair. The next input line for a test case contains an integer, q (1 ≤ q ≤ 100), indicating the number of strings to test for phoneme palindrome. Each of the following q input lines provides a string (starting in column 1 and lowercase letters only) of length 1 to 50, inclusive.

출력

For each test case, print the header “Test case #n:”, where n indicates the case number starting with 1. Then print each string for that test case followed by a space, followed by a message (YES or NO) indicating whether or not the string is a phoneme palindrome. Leave a blank line after the output for each test case.

제한

예제 입력 1

2
1
c k
6
a
cac
ck
cab
kaak
ckckkcck
2
a z
x s
5
abbbz
asxz
cx
sxxabzxss
ks

예제 출력 1

Test case #1:
a YES
cac YES
ck YES
cab NO
kaak YES
ckckkcck YES
Test case #2:
abbbz YES
asxz YES
cx NO
sxxabzxss YES
ks NO

힌트

출처

University > University of Central Florida > 2016 Local Programming Contest 2번

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

출처

대학교 대회

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

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