結果

問題 No.331 CodeRunnerでやれ
ユーザー LeonardoneLeonardone
提出日時 2015-12-24 06:11:35
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,052 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 31,484 KB
平均クエリ数 751.76
最終ジャッジ日時 2023-09-23 22:52:36
合計ジャッジ時間 12,324 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 223 ms
31,016 KB
testcase_01 AC 215 ms
31,464 KB
testcase_02 AC 282 ms
30,872 KB
testcase_03 AC 401 ms
30,852 KB
testcase_04 AC 374 ms
31,484 KB
testcase_05 AC 297 ms
30,908 KB
testcase_06 AC 561 ms
31,148 KB
testcase_07 AC 501 ms
31,312 KB
testcase_08 AC 745 ms
30,960 KB
testcase_09 AC 3,708 ms
31,444 KB
testcase_10 AC 547 ms
31,184 KB
testcase_11 AC 402 ms
31,100 KB
testcase_12 AC 720 ms
31,448 KB
testcase_13 AC 4,371 ms
31,232 KB
testcase_14 AC 1,963 ms
30,836 KB
testcase_15 AC 1,743 ms
15,496 KB
testcase_16 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gf() gets.to_f end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def gfs() gss.map(&:to_f) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|r,e| r[e]+=1;r} end
############################################################

=begin

最大でも20x20なんで
うまくやればTLEなんて起こらないはずなのに

壁伝いだと以下に気をつけるべき

ループに捕まると抜け出せない
##########
#.........
#..####..#
#.v#..#..#
#..####..#
#........#
##########

行き止まりも恐い
##########
#.#.......
#.#.######
#.#......#
#.#.######
#......v.#
##########

下手すると上下左右に単機ループがあるかもしれない
##########
#.........
#...#....#
#.#.v.#..#
#........#
#...#....#
#........#
##########

=end


UNKNOWN_CELL = 0
WALL_CELL = 1
SPACE_CELL = 2

f = arr2d(60, 60)
x = 30
y = 30
dx = 1
dy = 0
f[y][x] = SPACE_CELL

t = 0

loop {
    s = STDIN.gets
    break if s[0] == "M"
    if s.size > 2
        STDOUT.puts "F"
    else
        d = s.to_i
        if f[y + dy][x + dx] == UNKNOWN_CELL
            (1..d).each do |i|
                f[y + dy * i][x + dx * i] = SPACE_CELL
            end
            f[y + dy * d.succ][x + dx * d.succ] = WALL_CELL
            loop {
                flg = 0
                break if flg == 0
            }
        end
        if d > 0
            if t == 0
                puts "F"
                t = 1
            else
                puts "RLRFFFFF"[rand(6)]
                t = 0
            end
        else
            puts "LRL"[rand(3)]
        end
    end
    STDOUT.flush
}
0