結果
問題 |
No.331 CodeRunnerでやれ
|
ユーザー |
![]() |
提出日時 | 2022-07-27 00:59:32 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 721 ms / 5,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 29,144 KB |
平均クエリ数 | 721.65 |
最終ジャッジ日時 | 2024-07-17 03:09:48 |
合計ジャッジ時間 | 8,835 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
def send_query(str) STDOUT.puts(str) STDOUT.flush res = gets.chomp if res == "Merry Christmas!" -1 else res.to_i end end v = gets.to_i v.times do res = send_query("F") exit if res == -1 end send_query("R") step_cnt = 0 loop do res = send_query("L") if res > 0 && step_cnt > 1000 res.times do f = send_query("F") exit if f == -1 end send_query("R") step_cnt = 0 next end if res > 0 f = send_query("F") step_cnt += 1 if f < 0 exit end else f = send_query("R") if f > 0 r = send_query("F") step_cnt += 1 if r < 0 exit end else send_query("R") end end end