結果

問題 No.233 めぐるはめぐる (3)
ユーザー nuwasoginuwasogi
提出日時 2015-12-02 01:10:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 2,161 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 23,984 KB
最終ジャッジ日時 2023-10-12 08:32:23
合計ジャッジ時間 6,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 555 ms
23,984 KB
testcase_01 AC 310 ms
14,028 KB
testcase_02 AC 162 ms
11,152 KB
testcase_03 AC 351 ms
14,776 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
def isshiin(c):
    return (c !='a' and c!= 'u' and c!='i' and c!='e')

OriginalName ="inabameguru"
Shiin = "nbmgr"
Boin = "iaaeuu"

N = int(input())
S = [] # 使用済み名前のリスト
for x in range(N):
    S.append(input())
Ss = set() # 使用済み名前の子音列の集合
for x in S:
    Ss.add("".join(filter(isshiin, x)))
atode = [] # あとで試す子音列のリスト
flag = False # 終了フラグ
# すべての子音列について
for s in itertools.permutations(Shiin):
    pShiin = "".join(s) # sを文字列に変換
    # 使用済み子音列なら後で試す
    if(pShiin in Ss):
        atode.append(s)
        continue
    # 存在しない子音列なら母音はなんでもOK
    # すべての母音の並びについて
    result = ""
    for bb,ss in zip(Boin, pShiin):
        result += bb + ss
    result +=  Boin[5]
    flag = True
    break
#    for b in itertools.permutations(Boin):
#        for i in range(6):
#            result = ""
#            for j in range(i):
#                result += s[j]
#                result += b[j]
#            result += b[i]
#            for j in range(i, 5):
#                result += s[j]
#                result += b[j+1] 
#            if(result not in S):
#                flag = True
#                break
#        if(flag):
#            break
#    if(flag):
#        break
if(flag):
    print(result)
# 使用済み子音列で探索するしかない
else:
    # すべての子音列について
    for s in atode:
        # すべての母音列について
        for b in itertools.permutations(Boin):
            for i in range(6):
                result = ""
                for j in range(i):
                    result += s[j]
                    result += b[j]
                result += b[i]
                for j in range(i, 5):
                    result += s[j]
                    result += b[j+1] 
                if(result not in S):
                    flag = True
                    break
            if(flag):
                break
        if(flag):
            break
    if(flag):
        print(result)
    else:
        print("NO")
0