結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-08-21 02:43:24 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 789 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 73,472 KB |
| 最終ジャッジ日時 | 2024-10-14 11:21:44 |
| 合計ジャッジ時間 | 18,772 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 RE * 2 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
positions = Array.new(1_000_010, false)
A.each do |a|
positions[a] = true
end
def dfs(i, positions, commands)
while A[i] != B[i]
a = A[i]
if A[i] < B[i]
if positions[a + 1]
dfs(i + 1, positions, commands)
else
commands << [i, 'R']
positions[a] = false
positions[a + 1] = true
A[i] += 1
end
else
if positions[a - 1]
dfs(i + 1, positions, commands)
else
commands << [i, 'L']
positions[a] = false
positions[a - 1] = true
A[i] -= 1
end
end
end
end
commands = []
N.times do |i|
dfs(i, positions, commands)
end
puts commands.size
puts commands.map { |i, d| [i + 1, d].join(' ') }
siman