結果

問題 No.701 ひとりしりとり
ユーザー sekihankamibanzsekihankamibanz
提出日時 2018-10-29 21:45:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 609 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-04-29 23:17:57
合計ジャッジ時間 5,597 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
16,640 KB
testcase_01 AC 36 ms
11,008 KB
testcase_02 AC 36 ms
11,008 KB
testcase_03 RE -
testcase_04 AC 34 ms
11,008 KB
testcase_05 AC 33 ms
11,008 KB
testcase_06 AC 36 ms
11,008 KB
testcase_07 AC 42 ms
11,008 KB
testcase_08 AC 45 ms
11,136 KB
testcase_09 AC 63 ms
11,136 KB
testcase_10 AC 992 ms
11,776 KB
testcase_11 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random


n = int(input())
used_words = []

for i in range(n):
    while True:
        word_length = random.choice(range(20))
        if used_words:
            word = used_words[-1][-1] + ''.join([chr(97 + x) for x in random.choices(range(26), k=word_length)])
        else:
            word = ''.join([chr(97 + x) for x in random.choices(range(26), k=word_length)])
        if word[-1] == 'n' or word in used_words or ((i == n-1) and (len(word) == 20)):
            continue
        if i == n-1:
            word += 'n'
        used_words.append(word)
        break

for i in used_words:
    print(i)
0