結果

問題 No.701 ひとりしりとり
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2022-07-14 07:53:14
言語 Nim
(2.0.2)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 4,934 ms
コンパイル使用メモリ 69,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 20:11:29
合計ジャッジ時間 6,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 129 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils

let n = stdin.readLine.parseInt
var dic, last = ""

proc trfm(S: string): string =
  var bufStr = ""
  for s in S: bufStr.add (s.int - 'a'.int).repr
  let bufInt = bufStr.parseInt + 1
  for s in $bufInt:
    result.add ((s & "").parseInt + 'a'.int).chr

for c in ('a' .. 'y'): dic.add $c
dic.add "a"
dic = dic.replace("n", "z")

var cnt = 0
proc judge =
  cnt += 1
  if cnt >= n: echo last & "n"; quit()

var mid = "a"
while true:
  for i in 0 ..< dic.high:
    judge()
    echo dic[i] & mid & dic[i + 1]
    last = dic[i + 1] & ""
  mid = mid.trfm
0