Fix | 프로그래밍의 벗 PivotOJ
PivotOJ

Fix

시간 제한: 1000ms메모리 제한: 128MB출처: CCC 2004 SeniorBOJ 6892

문제

A collection of words is prefix-free if no word is a prefix of any other word. A collection of words is suffix-free if no word is a suffix of any other word. A collection of words is fix-free if it is both prefix-free and suffix-free.

For this problem, a word is a sequence of lower-case letters of length between 11 and 2525. A word XX is a prefix of word YY if XX consists of the first nn characters of YY, in order, for some nn. That is, the word cat has prefixes c, ca, and cat. Similarly, a word XX is a suffix of YY if XX consists of the last nn characters of YY, in order, for some nn.

Your input will be 3N+13N+1 lines: the first line will be the number NN, and the remaining 3N3N lines will be the NN collections of 33 words each. (That is, lines 22, 33, and 44 compose the first collection, lines 55, 66, and 77 compose the second collection, and so on). Your output will be NN lines, each line containing either Yes (if that collection of words is fix-free) or No (if that collection is not fix-free).

예제

예제 1

입력
2
abba
aab
bab
a
ab
aa
출력
Yes
No
코드를 제출하려면 로그인하세요.