結果

問題 No.233 めぐるはめぐる (3)
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-03-02 22:09:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 450 ms / 1,000 ms
コード長 1,014 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 11,900 KB
実行使用メモリ 22,372 KB
最終ジャッジ日時 2023-10-24 19:33:59
合計ジャッジ時間 6,251 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
22,108 KB
testcase_01 AC 180 ms
21,044 KB
testcase_02 AC 103 ms
14,512 KB
testcase_03 AC 195 ms
21,044 KB
testcase_04 AC 437 ms
22,372 KB
testcase_05 AC 414 ms
22,372 KB
testcase_06 AC 381 ms
22,372 KB
testcase_07 AC 450 ms
22,372 KB
testcase_08 AC 449 ms
22,372 KB
testcase_09 AC 29 ms
10,168 KB
testcase_10 AC 28 ms
10,168 KB
testcase_11 AC 29 ms
10,168 KB
testcase_12 AC 185 ms
21,044 KB
testcase_13 AC 274 ms
22,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3
# -*- coding: utf-8 -*-

import itertools


CONSONANTS = "nbmgr"
VOWELS = "iaaeuu"


def insert_char_after(base_string, char, index):
    if index == -1:
        return char + base_string
    else:
        return base_string[:index + 1] + char + base_string[index + 1:]


def solve(used_names):
    con_perms = itertools.permutations(CONSONANTS)
    vow_perms = set(itertools.permutations(VOWELS))
    for con_perm, vow_perm in itertools.product(con_perms, vow_perms):
        cons = "".join(con_perm)
        vows = "".join(vow_perm)
        vows_init = vows[0:5]
        vows_last = vows[-1]
        ten_str = "".join(a + b for a, b in zip(cons, vows))
        for i in range(-1, 10):
            cand = insert_char_after(ten_str, vows_last, i)
            if cand not in used_names:
                return cand
    else:
        return "NO"


def main():
    n = int(input())
    used_names = {input() for _ in range(n)}
    print(solve(used_names))


if __name__ == '__main__':
    main()
0