結果
問題 | No.678 2Dシューティングゲームの必殺ビーム |
ユーザー |
|
提出日時 | 2018-04-27 22:49:51 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 195 ms / 2,000 ms |
コード長 | 1,803 bytes |
コンパイル時間 | 3,835 ms |
コンパイル使用メモリ | 81,864 KB |
実行使用メモリ | 54,632 KB |
最終ジャッジ日時 | 2024-06-27 22:06:25 |
合計ジャッジ時間 | 7,372 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder678 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int xlb = sc.nextInt(); int xrb = sc.nextInt(); List<Pair> list = new ArrayList<>(n); for (int i = 0; i < n; i++) { int xl = sc.nextInt(); int yu = sc.nextInt(); int xr = sc.nextInt(); int yd = sc.nextInt(); list.add(new Pair(Math.max(0, xl), Math.max(0, yu), Math.min(1280, xr), Math.min(1680, yd), i)); } Collections.sort(list); int[] ans = new int[n]; boolean[] w = new boolean[1280 + 1]; Arrays.fill(w, true); for (int i = xlb; i <= xrb; i++) { w[i] = false; } for (int i = list.size() - 1; i >= 0; i--) { Pair e = list.get(i); boolean flag = false; for (int x = e.a; x <= e.c; x++) { if (!w[x]) { flag = true; } w[x] = true; } if (flag) { ans[e.n] = 1; } else { ans[e.n] = 0; } } for (int e : ans) { pr.println(e); } } static class Pair implements Comparable<Pair> { int a; int b; int c; int d; int n; Pair(int a, int b, int c, int d, int n) { this.a = a; this.b = b; this.c = c; this.d = d; this.n = n; } @Override public int compareTo(Pair o) { if (d == o.d) { return Integer.compare(c, o.c); } return Integer.compare(d, o.d); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())); pr = new Printer(System.out); solve(); // pr.close(); pr.flush(); // sc.close(); } static String INPUT = null; private static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }