結果
| 問題 | 
                            No.233 めぐるはめぐる (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-03-02 22:09:37 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 488 ms / 1,000 ms | 
| コード長 | 1,014 bytes | 
| コンパイル時間 | 272 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 23,164 KB | 
| 最終ジャッジ日時 | 2024-09-24 13:33:55 | 
| 合計ジャッジ時間 | 6,684 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 | 
ソースコード
#!/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()