結果

問題 No.232 めぐるはめぐる (2)
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-16 00:59:30
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 11,412 KB
実行使用メモリ 23,172 KB
最終ジャッジ日時 2023-10-11 16:43:53
合計ジャッジ時間 6,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
23,092 KB
testcase_01 AC 197 ms
21,440 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 80 ms
15,248 KB
testcase_05 WA -
testcase_06 AC 80 ms
15,024 KB
testcase_07 AC 82 ms
15,240 KB
testcase_08 WA -
testcase_09 AC 82 ms
15,160 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 80 ms
15,240 KB
testcase_13 AC 80 ms
15,192 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 80 ms
15,160 KB
testcase_17 AC 81 ms
15,252 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 83 ms
15,136 KB
testcase_22 AC 82 ms
15,116 KB
testcase_23 AC 81 ms
15,156 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

str = gets.split
t = str[0].to_i
tx = str[1].to_i
ty = str[2].to_i
cx = 0
cy = 0
trace = Array.new
count = 0
d = (tx > ty) ? tx : ty
diff = t - d
if diff < 0
    puts "NO"
    exit
end
(diff / 2).times do
    trace.push(">")
    trace.push("<")
    count += 2
end
if diff % 2 == 1
    if tx > 0 && ty > 0
        if tx > ty
            trace.push("^")
            cy += 1
        else
            trace.push(">")
            cx += 1
        end
    elsif tx == 0 && ty > 0
        trace.push(">")
        cx += 1
    elsif tx > 0 && ty == 0
        trace.push("^")
        cy += 1
    else
        trace.delete_at(trace.length - 1)
        trace.delete_at(trace.length - 1)
        trace.push("^")
        trace.push(">")
        trace.push("v<")
    end
    count += 1
end
while count < t do
    s = ""
    if cx < tx
        s += ">"
        cx += 1
    elsif cx > tx
        s += "<"
        cx -= 1
    end
    if cy < ty
        s += "^"
        cy += 1
    elsif cy > ty
        s += "v"
        cy -= 1
    end
    trace.push(s)
    count += 1
end
if cx == tx && cy == ty
    puts "YES"
    puts trace
else
    puts "NO"
end
0