結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー tentententen
提出日時 2021-03-16 12:18:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,859 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 78,708 KB
実行使用メモリ 39,156 KB
最終ジャッジ日時 2024-04-25 11:28:13
合計ジャッジ時間 4,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,040 KB
testcase_01 AC 50 ms
37,176 KB
testcase_02 AC 52 ms
37,100 KB
testcase_03 AC 49 ms
36,968 KB
testcase_04 AC 56 ms
37,592 KB
testcase_05 AC 81 ms
38,104 KB
testcase_06 AC 74 ms
37,856 KB
testcase_07 AC 52 ms
37,000 KB
testcase_08 AC 55 ms
37,332 KB
testcase_09 AC 67 ms
37,484 KB
testcase_10 AC 58 ms
37,140 KB
testcase_11 AC 57 ms
37,020 KB
testcase_12 AC 56 ms
36,664 KB
testcase_13 AC 68 ms
37,972 KB
testcase_14 AC 75 ms
39,156 KB
testcase_15 AC 74 ms
38,840 KB
testcase_16 AC 58 ms
37,624 KB
testcase_17 AC 69 ms
37,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 3);
		int n = Integer.parseInt(first[0]);
		TreeSet<Integer> beam = new TreeSet<>();
		for (int i = Integer.parseInt(first[1]); i <= Integer.parseInt(first[2]); i++) {
		    beam.add(i);
		}
		Enemy[] enemies = new Enemy[n];
		PriorityQueue<Enemy> queue = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
		    String[] line = br.readLine().split(" ", 4);
		    enemies[i] = new Enemy(Integer.parseInt(line[0]), Integer.parseInt(line[1]), Integer.parseInt(line[2]));
		    queue.add(enemies[i]);
		}
		while (queue.size() > 0) {
		    Enemy e = queue.poll();
		    Integer left = beam.floor(e.right);
		    Integer right = beam.ceiling(e.left);
		    if ((left != null && left >= e.left) || (right != null && right <= e.right)) {
		        for (int i = e.left; i <= e.right; i++) {
		            beam.remove(i);
		        }
		        e.check();
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (Enemy e : enemies) {
		    if (e.checked()) {
		        sb.append(1);
		    } else {
		        sb.append(0);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
   }
   
   static class Enemy implements Comparable<Enemy> {
       int left;
       int right;
       int hor;
       boolean hit;
       
       public Enemy(int left, int hor, int right) {
           this.left = left;
           this.hor = hor;
           this.right = right;
       }
       
       public int compareTo(Enemy another) {
           return - hor + another.hor;
       }
       
       public void check() {
           hit = true;
       }
       
       public boolean checked() {
           return hit;
       }
   }
}
0