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

19356번 - Spoonerisms 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB112241717.526%

문제

A spoonerism (named after William Archibald Spooner, an Oxford pastor who had a habit of inadvertently inventing more of them) is a pair of words that you can change into another pair by swapping their beginnings, for example a "blushing crow" becomes a "crushing blow".

Given a list of words, find a spoonerism among them. Formally: find a pair $(A,B)$ of words from the list which can be split into $A = pq$ and $B = rs$ in such a manner that the words $C = rq$ and $D = ps$ are also on the list. We allow only true spoonerisms, that is, those with $p \neq r,ドル $s \neq q$ and $p, q, r, s$ nonempty.

입력

The first line of input contains the number of test cases $z$. The descriptions of the test cases follow.

The first line of each test case contains the length of the list $n$ (1ドル \leq n \leq 500,000円$). Each of the following $n$ lines contains a single word composed of small English letters. The total length of words in all test cases does not exceed 500ドル,000円$.

출력

For each test case, if no spoonerism can be found, output "NO" on a single line. If there is a spoonerism, output a line containing "YES", followed by a line containing words $A$ and $B,ドル and another one containing $C$ and $D$. If there are multiple solutions, output any one of them. You may also safely switch the word order in any line.

제한

예제 입력 1

1
9
blunder
blushing
crow
cry
crushing
blow
black
back
clap

예제 출력 1

YES
blushing crow
crushing blow

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 1: Jagiellonian U Contest J번

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

출처

대학교 대회

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

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