結果
問題 | No.701 ひとりしりとり |
ユーザー | hedwig100 |
提出日時 | 2020-05-06 16:59:27 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 916 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 10,856 KB |
実行使用メモリ | 20,976 KB |
最終ジャッジ日時 | 2023-09-11 04:13:16 |
合計ジャッジ時間 | 1,613 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,160 KB |
testcase_01 | AC | 16 ms
8,096 KB |
testcase_02 | AC | 16 ms
8,224 KB |
testcase_03 | AC | 17 ms
8,176 KB |
testcase_04 | AC | 16 ms
8,200 KB |
testcase_05 | AC | 17 ms
8,144 KB |
testcase_06 | AC | 16 ms
8,252 KB |
testcase_07 | AC | 17 ms
8,160 KB |
testcase_08 | AC | 16 ms
8,252 KB |
testcase_09 | AC | 17 ms
8,304 KB |
testcase_10 | AC | 23 ms
9,292 KB |
testcase_11 | AC | 77 ms
20,976 KB |
ソースコード
import sys sys.setrecursionlimit(100000000) input = sys.stdin.readline MOD = 10 ** 9 + 7 INF = 10 ** 15 from itertools import permutations def main(): N = int(input()) if N == 1: print('n') return shiritori = ['a'] itr = permutations('abcedfghijklmnopqrstuvwxyz',18) before = ''.join(next(itr)) i = 0 length = 1 while length < N: if length == N - 1: shiritori.append(chr(i%26 + 97) + 'n') break if i%26 == 13: i += 1 continue word = chr(i%26 + 97) if word == 'a': before = ''.join(next(itr)) word += before if i%26 == 12: word += chr((i + 2)%26 + 97) else: word += chr((i + 1)%26 + 97) shiritori.append(word) i += 1 length += 1 print('\n'.join(shiritori)) if __name__ == '__main__': main()