結果
問題 | No.233 めぐるはめぐる (3) |
ユーザー | rpy3cpp |
提出日時 | 2015-06-27 00:09:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 368 ms / 1,000 ms |
コード長 | 1,855 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 26,284 KB |
最終ジャッジ日時 | 2024-07-07 19:29:59 |
合計ジャッジ時間 | 4,986 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 254 ms
25,792 KB |
testcase_01 | AC | 178 ms
22,760 KB |
testcase_02 | AC | 97 ms
16,384 KB |
testcase_03 | AC | 191 ms
23,564 KB |
testcase_04 | AC | 368 ms
26,284 KB |
testcase_05 | AC | 284 ms
26,196 KB |
testcase_06 | AC | 320 ms
26,156 KB |
testcase_07 | AC | 242 ms
20,096 KB |
testcase_08 | AC | 251 ms
20,096 KB |
testcase_09 | AC | 28 ms
10,880 KB |
testcase_10 | AC | 28 ms
11,008 KB |
testcase_11 | AC | 26 ms
10,752 KB |
testcase_12 | AC | 178 ms
22,776 KB |
testcase_13 | AC | 254 ms
26,184 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))