結果

問題 No.233 めぐるはめぐる (3)
ユーザー maspymaspy
提出日時 2020-02-06 10:21:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 569 ms / 1,000 ms
コード長 907 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 102,132 KB
最終ジャッジ日時 2023-10-25 09:21:35
合計ジャッジ時間 5,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
87,044 KB
testcase_01 AC 61 ms
70,612 KB
testcase_02 AC 50 ms
63,044 KB
testcase_03 AC 64 ms
74,404 KB
testcase_04 AC 549 ms
102,116 KB
testcase_05 AC 318 ms
102,132 KB
testcase_06 AC 225 ms
102,132 KB
testcase_07 AC 562 ms
102,132 KB
testcase_08 AC 569 ms
102,132 KB
testcase_09 AC 39 ms
53,404 KB
testcase_10 AC 39 ms
53,404 KB
testcase_11 AC 39 ms
53,404 KB
testcase_12 AC 63 ms
72,068 KB
testcase_13 AC 75 ms
81,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N = int(readline())
S = frozenset(read().decode().split())

def gen_consonant_indices():
    for p in itertools.combinations(range(10), 5):
        if all(x + 1 != y for x, y in zip(p, p[1:])):
            yield p

def solve():
    for I in gen_consonant_indices():
        J = [i for i in range(11) if i not in I]
        for perm_1 in itertools.permutations('nbmgr'):
            for perm_2 in itertools.permutations('iaaeuu'):
                name = [None] * 11
                for i, p in zip(I, perm_1):
                    name[i] = p
                for i, p in zip(J, perm_2):
                    name[i] = p
                name = ''.join(name)
                if name in S:
                    continue
                return name
    return 'NO'

print(solve())
0