RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
ICPC00077

I. Secret Chamber at Mount Rushmore

Unrated 레이팅 미적용
난이도
1s
시간 제한
1024MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

By now you have probably heard that there is a spectacular stone scu\(lp- tu\)re featuring four famous U.S. presidents at Mount Rushmore. H\(ow- ev\)er, very few people know that this monument contains a secret ch\(am- be\)r. This sounds like something out of a plot of a Hollywood movie, but the chamber really exists. It can be found behind the head of Abraham Lincoln and was designed to serve as a Hall of Records to store imp\(or- ta\)nt historical U.S. documents and artifacts. Historians claim that the construction of the hall was halted in 1939 and the uncompleted ch\(am- be\)r was left untouched until the late 1990s, but this is not the whole truth. In 1982, the famous archaeologist S. Dakota Jones secretly visited the monument and found that the chamber actually was completed, but it was kept confidential. This seemed suspicious and after some poking around, she found a hidden vault and some documents inside. Unfor\(tu- na\)tely, these documents did not make any sense and were all gibberish. She suspected that they had been written in a code, but she could not decipher them despite all her efforts. Earlier this week when she was in the area to follow the A\(CM-IC\)PC World Finals, Dr. Jones finally d\(is- co\)vered the key to deciphering the documents, in Connolly Hall of SDSM&T. She found a document that contains a list of translations of letters. Some letters may have more than one translation, and others may have no translation. By repeatedly applying some of these translations to individual letters in the gibberish documents, she might be able to decipher them to yield historical U.S. documents such as the Declaration of Independence and the Constitution. She needs your help. You are given the possible translations of letters and a list of pairs of original and deciphered words. Your task is to verify whether the words in each pair match. Two words match if they have the same length and if each letter of the first word can be turned into the corresponding letter of the second word by using the available translations zero or more times.

제약
입력 형식

The first line of input contains two integers \(m\) (\(1 \le m \le 500\)) and \(n\) (\(1 \le n \le 50\)), where \(m\) is the number of translations of letters and \(n\) is the number of word pairs. Each of the next \(m\) lines contains two distinct spa\(ce-se\)parated letters \(a\) and \(b\), indicating that the letter \(a\) can be translated to the letter \(b\). Each ordered pair of letters (a, b) appears at most once. Following this are \(n\) lines, each containing a word pair to check. Translations and words use only lowercase letters ‘a’–‘z’, and each word contains at least 1 and at most 50 letters.

출력 형식

For each pair of words, display yes if the two words match, and no otherwise.

예제 1
입력
9 5
c t
i r
k p
o c
r o
t e
t f
u h
w p
we we
can the
work people
it of
out the
출력
yes
no
no
yes
yes
예제 2
입력
3 3
a c
b a
a b
aaa abc
abc aaa
acm bcm
출력
yes
no
yes
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC World Finals 2017

평가 및 의견

I. Secret Chamber at Mount Rushmore

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

I. Secret Chamber at Mount Rushmore

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8