結果
問題 | No.202 1円玉投げ |
ユーザー | fujisu |
提出日時 | 2015-05-09 06:24:14 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,493 bytes |
コンパイル時間 | 2,650 ms |
コンパイル使用メモリ | 78,660 KB |
実行使用メモリ | 76,268 KB |
最終ジャッジ日時 | 2024-12-22 08:49:02 |
合計ジャッジ時間 | 49,488 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
ソースコード
import java.io.IOException; import java.util.HashSet; import java.util.InputMismatchException; public class Main { class Point implements Comparable<Point> { int x, y; Point(int x, int y) { this.x = x; this.y = y; } @Override public int compareTo(Point o) { return this.x != o.x ? this.x - o.x : this.y - o.y; } } boolean isIntersect(int x, int y, int a, int b) { return (x - a) * (x - a) + (y - b) * (y - b) < 400; } void run() { MyScanner sc = new MyScanner(); HashSet<Integer>[] set = new HashSet[20001]; for (int i = 0; i < 20001; i++) { set[i] = new HashSet<Integer>(); } int n = sc.nextInt(); long f1 = System.currentTimeMillis(); int ans = 0; L: for (int i = 0; i < n; i++) { int x = sc.nextInt(); int y = sc.nextInt(); int minX = Math.max(x - 19, 0); int maxX = Math.min(x + 19, 20000); // int minY = Math.max(y - 19, 0); // int maxY = Math.min(y + 19, 20000); for (int j = minX; j <= maxX; j++) { int dy = (int) Math.sqrt(399 - (j - x) * (j - x) + 0.0001); // for (int k = minY; k <= maxY; k++) { int minY = Math.max(y - dy, 0); int maxY = Math.min(y + dy, 20000); for (int k = minY; k <= maxY; k++) { if (!isIntersect(x, y, j, k)) { continue; } if (!set[j].contains(k)) { continue; } if (isIntersect(x, y, j, k)) { continue L; } } } set[x].add(y); ans++; } System.out.println(ans); long f2 = System.currentTimeMillis(); System.out.println(f2 - f1); } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------" + '\n'); } class MyScanner { int read() { try { return System.in.read(); } catch (IOException e) { throw new InputMismatchException(); } } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }