結果

問題 No.233 めぐるはめぐる (3)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-02 11:49:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 337 ms / 1,000 ms
コード長 1,058 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 98,784 KB
最終ジャッジ日時 2023-10-24 19:31:51
合計ジャッジ時間 6,931 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 331 ms
98,784 KB
testcase_01 AC 304 ms
98,324 KB
testcase_02 AC 278 ms
97,436 KB
testcase_03 AC 314 ms
96,884 KB
testcase_04 AC 337 ms
97,776 KB
testcase_05 AC 335 ms
97,776 KB
testcase_06 AC 331 ms
97,776 KB
testcase_07 AC 331 ms
97,776 KB
testcase_08 AC 330 ms
97,776 KB
testcase_09 AC 245 ms
97,940 KB
testcase_10 AC 242 ms
97,944 KB
testcase_11 AC 228 ms
91,356 KB
testcase_12 AC 306 ms
98,428 KB
testcase_13 AC 327 ms
97,712 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):
    all_names = set()
    con_perms = itertools.permutations(CONSONANTS)
    vow_perms = 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):
            all_names.add(insert_char_after(ten_str, vows_last, i))
    return all_names - used_names


def main():
    n = int(input())
    used_names = {input() for _ in range(n)}
    answers = solve(used_names)
    if not answers:
        print("NO")
    else:
        print(answers.pop())


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