結果

問題 No.701 ひとりしりとり
ユーザー ThetaTheta
提出日時 2022-12-02 19:00:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-18 02:41:54
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
11,520 KB
testcase_01 AC 40 ms
11,648 KB
testcase_02 AC 37 ms
11,392 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import re
from string import ascii_lowercase
from typing import Optional


class SelfShiritori:
    def __init__(self) -> None:
        self.start_letter_state = {letter: 0 for letter in ascii_lowercase}

    def create_word(self, start: str, end: Optional[str] = None) -> str:
        return_str = start
        return_str += chr(97 +
                          (self.start_letter_state[start] // (26 ** 3)) % 26)
        return_str += chr(97 +
                          (self.start_letter_state[start] // (26 ** 2)) % 26)
        return_str += chr(97 + (self.start_letter_state[start] // 26 % 26))
        return_str += chr(97 + (self.start_letter_state[start] % 26))
        if end is not None:
            return_str += end
        else:
            return_str += chr((ord(start)-96) % 26 + 97)

        self.start_letter_state[start] += 1
        return return_str


def main():
    n = int(input())
    shiritori = SelfShiritori()
    for idx in range(n-1):
        print(shiritori.create_word(chr(97 + idx % 26), ))

    print(shiritori.create_word(chr(97 + (n-1) % 26), "n"))


if __name__ == "__main__":
    main()
0