結果

問題 No.233 めぐるはめぐる (3)
ユーザー H3PO4H3PO4
提出日時 2020-06-02 23:15:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 427 ms / 1,000 ms
コード長 676 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 100,440 KB
最終ジャッジ日時 2024-11-24 16:38:06
合計ジャッジ時間 7,709 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N = int(input())
S = set(input() for _ in range(N))

anagrams = set()


def make_str(consonant, vowel, dup):
    s = ''
    dup_flag = True
    for i in range(11):
        if dup * 2 <= i:
            dup_flag = False
        if dup_flag ^ (i % 2):
            s += next(consonant)
        else:
            s += next(vowel)
    return s


for consonant in itertools.permutations(('n', 'b', 'm', 'g', 'r')):
    for vowel in itertools.permutations(('i', 'a', 'a', 'e', 'u', 'u')):
        for dup in range(6):
            anagrams.add(make_str(iter(consonant), iter(vowel), dup))

if N == len(anagrams):
    print('NO')
else:
    print((anagrams - S).pop())
0