結果
| 問題 | No.232 めぐるはめぐる (2) | 
| コンテスト | |
| ユーザー |  小指が強い人 | 
| 提出日時 | 2015-11-16 01:16:31 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 215 ms / 1,000 ms | 
| コード長 | 1,045 bytes | 
| コンパイル時間 | 272 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 20,736 KB | 
| 最終ジャッジ日時 | 2024-09-14 12:40:01 | 
| 合計ジャッジ時間 | 4,698 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
コンパイルメッセージ
Syntax OK
ソースコード
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
            
            
            
        