結果
| 問題 |
No.678 2Dシューティングゲームの必殺ビーム
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-03-16 12:18:53 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| コード長 | 1,859 bytes |
| コンパイル時間 | 3,073 ms |
| コンパイル使用メモリ | 78,988 KB |
| 実行使用メモリ | 39,308 KB |
| 最終ジャッジ日時 | 2024-11-07 22:48:51 |
| 合計ジャッジ時間 | 5,306 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
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;
}
}
}
tenten