結果

問題 No.701 ひとりしりとり
コンテスト
ユーザー letrangerjp
提出日時 2018-06-15 22:31:16
言語 Ruby
(4.0.1)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 305 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 181 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 30,764 KB
最終ジャッジ日時 2026-03-20 18:09:40
合計ジャッジ時間 2,166 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

N = gets.to_i

memo = {}
chars = [*?a..?z]
last_chars = [*?a..?z]-[?n]
first_char = chars.sample

(N-1).times{
  last_char = last_chars.sample
  s = first_char + rand(0..18).times.map{chars.sample}*"" + last_char
  redo if memo[s]
  memo[s] = true
  puts s
  first_char = last_char
}
puts first_char + ?n
0