結果
| 問題 |
No.232 めぐるはめぐる (2)
|
| コンテスト | |
| ユーザー |
小指が強い人
|
| 提出日時 | 2015-11-16 00:59:30 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,131 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 20,864 KB |
| 最終ジャッジ日時 | 2024-09-13 15:21:58 |
| 合計ジャッジ時間 | 5,851 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 12 |
コンパイルメッセージ
Syntax OK
ソースコード
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
小指が強い人