結果
問題 | No.947 ABC包囲網 |
ユーザー | hiromi_ayase |
提出日時 | 2019-12-12 04:51:40 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 541 ms / 2,000 ms |
コード長 | 3,451 bytes |
コンパイル時間 | 3,130 ms |
コンパイル使用メモリ | 89,588 KB |
実行使用メモリ | 53,856 KB |
最終ジャッジ日時 | 2024-06-24 08:33:02 |
合計ジャッジ時間 | 19,960 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
51,048 KB |
testcase_01 | AC | 78 ms
51,548 KB |
testcase_02 | AC | 79 ms
51,452 KB |
testcase_03 | AC | 79 ms
51,184 KB |
testcase_04 | AC | 79 ms
51,300 KB |
testcase_05 | AC | 79 ms
51,304 KB |
testcase_06 | AC | 79 ms
51,172 KB |
testcase_07 | AC | 79 ms
51,236 KB |
testcase_08 | AC | 80 ms
51,468 KB |
testcase_09 | AC | 79 ms
51,348 KB |
testcase_10 | AC | 78 ms
51,344 KB |
testcase_11 | AC | 79 ms
51,048 KB |
testcase_12 | AC | 81 ms
51,256 KB |
testcase_13 | AC | 77 ms
51,504 KB |
testcase_14 | AC | 81 ms
51,520 KB |
testcase_15 | AC | 97 ms
52,176 KB |
testcase_16 | AC | 98 ms
52,380 KB |
testcase_17 | AC | 98 ms
52,080 KB |
testcase_18 | AC | 101 ms
52,180 KB |
testcase_19 | AC | 99 ms
51,956 KB |
testcase_20 | AC | 101 ms
52,176 KB |
testcase_21 | AC | 101 ms
52,332 KB |
testcase_22 | AC | 100 ms
52,044 KB |
testcase_23 | AC | 100 ms
52,304 KB |
testcase_24 | AC | 100 ms
52,292 KB |
testcase_25 | AC | 104 ms
52,260 KB |
testcase_26 | AC | 105 ms
52,000 KB |
testcase_27 | AC | 101 ms
52,100 KB |
testcase_28 | AC | 492 ms
53,536 KB |
testcase_29 | AC | 526 ms
53,836 KB |
testcase_30 | AC | 539 ms
53,304 KB |
testcase_31 | AC | 530 ms
53,772 KB |
testcase_32 | AC | 532 ms
53,524 KB |
testcase_33 | AC | 533 ms
53,440 KB |
testcase_34 | AC | 523 ms
53,832 KB |
testcase_35 | AC | 513 ms
53,696 KB |
testcase_36 | AC | 531 ms
53,568 KB |
testcase_37 | AC | 527 ms
53,340 KB |
testcase_38 | AC | 536 ms
53,768 KB |
testcase_39 | AC | 527 ms
53,576 KB |
testcase_40 | AC | 515 ms
53,460 KB |
testcase_41 | AC | 512 ms
53,676 KB |
testcase_42 | AC | 521 ms
53,352 KB |
testcase_43 | AC | 528 ms
53,536 KB |
testcase_44 | AC | 523 ms
53,732 KB |
testcase_45 | AC | 521 ms
53,696 KB |
testcase_46 | AC | 510 ms
53,612 KB |
testcase_47 | AC | 541 ms
53,856 KB |
testcase_48 | AC | 536 ms
53,492 KB |
testcase_49 | AC | 528 ms
53,800 KB |
testcase_50 | AC | 508 ms
53,308 KB |
testcase_51 | AC | 89 ms
51,688 KB |
testcase_52 | AC | 88 ms
51,560 KB |
testcase_53 | AC | 88 ms
51,872 KB |
testcase_54 | AC | 79 ms
51,348 KB |
testcase_55 | AC | 79 ms
51,520 KB |
testcase_56 | AC | 78 ms
51,100 KB |
testcase_57 | AC | 99 ms
52,000 KB |
testcase_58 | AC | 96 ms
52,180 KB |
testcase_59 | AC | 99 ms
52,004 KB |
ソースコード
import java.util.Arrays; public class Main { private static void solve() { int n = ni(); int[][] p = ntable(n, 2); double[] theta1 = new double[n]; double[] theta2 = new double[n]; for (int i = 0; i < n; i++) { theta1[i] = theta2[i] = Math.atan2(p[i][1], p[i][0]) + Math.PI; theta2[i] += Math.PI * 2; } Arrays.sort(theta1); Arrays.sort(theta2); long ret = 0; double eps = 0.000000000001; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { double s = theta1[i]; double t = theta1[j]; if (t - s + eps >= Math.PI) { break; } int x = lowerBound(theta2, Math.PI + s + eps, i); int y = lowerBound(theta2, Math.PI + t - eps, i); ret += Math.max(0, y - x); } } System.out.println(ret); } public static int lowerBound(double[] a, double v, int to) { int low = -1, high = to; while (high - low > 1) { int h = high + low >>> 1; if (a[h] >= v) { high = h; } else { low = h; } } return high; } public static void main(String[] args) { new Thread(null, new Runnable() { @Override public void run() { long start = System.currentTimeMillis(); String debug = args.length > 0 ? args[0] : null; if (debug != null) { try { is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug)); } catch (Exception e) { throw new RuntimeException(e); } } reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768); solve(); out.flush(); tr((System.currentTimeMillis() - start) + "ms"); } }, "", 64000000).start(); } private static java.io.InputStream is = System.in; private static java.io.PrintWriter out = new java.io.PrintWriter(System.out); private static java.util.StringTokenizer tokenizer = null; private static java.io.BufferedReader reader; public static String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new java.util.StringTokenizer(reader.readLine()); } catch (Exception e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } private static double nd() { return Double.parseDouble(next()); } private static long nl() { return Long.parseLong(next()); } private static int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ni(); return a; } private static char[] ns() { return next().toCharArray(); } private static long[] nal(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nl(); return a; } private static int[][] ntable(int n, int m) { int[][] table = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[i][j] = ni(); } } return table; } private static int[][] nlist(int n, int m) { int[][] table = new int[m][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[j][i] = ni(); } } return table; } private static int ni() { return Integer.parseInt(next()); } private static void tr(Object... o) { if (is != System.in) System.out.println(java.util.Arrays.deepToString(o)); } }