結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー | rpy3cpp |
提出日時 | 2015-06-27 00:09:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 383 ms / 1,000 ms |
コード長 | 1,855 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 10,788 KB |
実行使用メモリ | 23,776 KB |
最終ジャッジ日時 | 2023-09-22 02:42:30 |
合計ジャッジ時間 | 5,567 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 243 ms
23,340 KB |
testcase_01 | AC | 165 ms
20,108 KB |
testcase_02 | AC | 90 ms
13,792 KB |
testcase_03 | AC | 181 ms
20,776 KB |
testcase_04 | AC | 301 ms
23,596 KB |
testcase_05 | AC | 383 ms
23,736 KB |
testcase_06 | AC | 367 ms
23,776 KB |
testcase_07 | AC | 225 ms
17,708 KB |
testcase_08 | AC | 223 ms
17,732 KB |
testcase_09 | AC | 18 ms
8,416 KB |
testcase_10 | AC | 19 ms
8,536 KB |
testcase_11 | AC | 17 ms
8,412 KB |
testcase_12 | AC | 163 ms
20,268 KB |
testcase_13 | AC | 239 ms
23,568 KB |
ソースコード
import itertools def read_data(): N = int(input()) Ss = [input() for i in range(N)] return N, Ss def solve(N, Ss): ''' n[]b[]m[]g[]r[] [] には、母音が必ず必要。 残りの母音は、任意の位置に挿入可能。 ''' original = 'inabameguru' if N == 0: return original vowels = [ ['aa','i','e','u','u'], ['a','ai','e','u','u'], ['a','ia','e','u','u'], ['a','i','ae','u','u'], ['a','i','ea','u','u'], ['a','i','e','au','u'], ['a','i','e','ua','u'], ['a','a','ie','u','u'], ['a','a','ei','u','u'], ['a','a','e','iu','u'], ['a','a','e','ui','u'], ['a','a','i','eu','u'], ['a','a','i','ue','u'], ['a','a','i','e','uu'], ['a', 'a', 'i', 'e', 'u', 'u']] cons = ['n', 'b', 'm', 'g', 'r'] vowel_perm5 = set() for vowel in vowels[:-1]: for permutated in itertools.permutations(vowel): vowel_perm5.add(permutated) vowel_perm6 = set() for permutated in itertools.permutations(vowels[-1]): vowel_perm6.add(permutated) cons_perm = set() for permutated in itertools.permutations(cons): cons_perm.add(permutated) n_max = len(cons_perm) * (len(vowel_perm5) + len(vowel_perm6)) if N == n_max: return 'NO' used = set(Ss) for con in cons_perm: for vowel5 in vowel_perm5: handle = ''.join([a + b for a, b in zip(con, vowel5)]) if handle not in used: return handle for vowel6 in vowel_perm6: handle = vowel6[0] + ''.join([a + b for a, b in zip(con, vowel6[1:])]) if handle not in used: return handle N, Ss = read_data() print(solve(N, Ss))