結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー maimai
提出日時 2018-04-27 22:59:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2023-09-10 06:41:22
合計ジャッジ時間 2,642 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,084 KB
testcase_01 AC 81 ms
15,300 KB
testcase_02 AC 81 ms
15,308 KB
testcase_03 AC 81 ms
15,132 KB
testcase_04 AC 81 ms
15,312 KB
testcase_05 AC 81 ms
15,124 KB
testcase_06 AC 82 ms
15,268 KB
testcase_07 AC 82 ms
15,092 KB
testcase_08 AC 80 ms
15,180 KB
testcase_09 AC 81 ms
15,168 KB
testcase_10 AC 81 ms
15,144 KB
testcase_11 AC 81 ms
15,044 KB
testcase_12 AC 81 ms
15,040 KB
testcase_13 AC 80 ms
15,124 KB
testcase_14 AC 81 ms
15,312 KB
testcase_15 AC 83 ms
15,040 KB
testcase_16 AC 80 ms
15,256 KB
testcase_17 AC 81 ms
15,360 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:21: warning: assigned but unused variable - pr
Main.rb:21: warning: assigned but unused variable - top
Main.rb:21: warning: assigned but unused variable - bottom
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i);end

N, beam_left, beam_right = ascan


beam = [false]*1282
beam_left.upto(beam_right){|x| beam[x] = true}


enemies = (0...N).map do |i|
    left, top, right, bottom = ascan
    [-bottom, i, left, top, right, bottom]
end

enemies.sort!


ans = [0]*N

enemies.each do |enemy|
    pr, index, left, top, right, bottom = enemy
    
    left = [left, -1].max
    right = [right, 1281].min
    
    hit = false
    left.upto(right) do |x|
        hit ||= beam[x]
        beam[x] = false
    end
    
    ans[index] = hit ? 1 : 0
end


puts ans*"\n"

0