結果

問題 No.701 ひとりしりとり
ユーザー ThetaTheta
提出日時 2022-10-18 16:23:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 10,104 KB
最終ジャッジ日時 2023-09-11 09:31:28
合計ジャッジ時間 3,203 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
9,760 KB
testcase_01 AC 32 ms
9,760 KB
testcase_02 AC 32 ms
9,760 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