結果

問題 No.233 めぐるはめぐる (3)
コンテスト
ユーザー norioc
提出日時 2025-11-24 04:01:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 352 ms / 1,000 ms
コード長 709 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 92,204 KB
最終ジャッジ日時 2025-11-24 04:01:59
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import permutations

consonants = 'nbmgr'
vowels = 'iaaeuu'

N = int(input())
SS = [input() for _ in range(N)]


def solve():
    used = set(SS)
    for a in permutations(consonants):
        for b in permutations(vowels):
            for i in range(5):
                c = b[0]
                cs = []
                for j, ab in enumerate(zip(a, b[1:])):
                    if i == j:
                        cs.append(c)
                    cs.append(ab[0])
                    cs.append(ab[1])

                s = ''.join(cs)
                if s not in used:
                    print(s)
                    return True

    return False


found = solve()
if not found:
    print('NO')
0