結果

問題 No.232 めぐるはめぐる (2)
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-16 01:16:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 198 ms / 1,000 ms
コード長 1,045 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 11,320 KB
実行使用メモリ 23,136 KB
最終ジャッジ日時 2023-10-12 13:42:57
合計ジャッジ時間 4,869 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
23,136 KB
testcase_01 AC 198 ms
21,416 KB
testcase_02 AC 139 ms
23,016 KB
testcase_03 AC 162 ms
21,748 KB
testcase_04 AC 79 ms
15,076 KB
testcase_05 AC 78 ms
15,252 KB
testcase_06 AC 80 ms
15,080 KB
testcase_07 AC 83 ms
15,108 KB
testcase_08 AC 155 ms
20,584 KB
testcase_09 AC 80 ms
15,260 KB
testcase_10 AC 81 ms
15,260 KB
testcase_11 AC 82 ms
15,224 KB
testcase_12 AC 82 ms
15,076 KB
testcase_13 AC 81 ms
15,252 KB
testcase_14 AC 79 ms
15,072 KB
testcase_15 AC 79 ms
15,284 KB
testcase_16 AC 81 ms
15,104 KB
testcase_17 AC 80 ms
15,320 KB
testcase_18 AC 83 ms
15,072 KB
testcase_19 AC 81 ms
15,208 KB
testcase_20 AC 81 ms
15,328 KB
testcase_21 AC 82 ms
15,240 KB
testcase_22 AC 81 ms
15,068 KB
testcase_23 AC 83 ms
15,116 KB
testcase_24 AC 84 ms
15,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

str = gets.split
t = str[0].to_i
ty = str[1].to_i
tx = str[2].to_i
cy = 0
cx = 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 trace.length == 0
            puts "NO"
            exit
        end
        trace.delete_at(trace.length - 1)
        trace.delete_at(trace.length - 1)
        trace.push("^")
        trace.push(">")
        trace.push("v<")
    elsif tx >= ty
        trace.push("^")
        cy += 1
    elsif tx < ty
        trace.push(">")
        cx += 1
    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