結果
問題 | No.947 ABC包囲網 |
ユーザー | mkawa2 |
提出日時 | 2021-03-18 22:34:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 724 ms / 2,000 ms |
コード長 | 1,304 bytes |
コンパイル時間 | 355 ms |
コンパイル使用メモリ | 81,980 KB |
実行使用メモリ | 78,936 KB |
最終ジャッジ日時 | 2024-11-17 04:46:50 |
合計ジャッジ時間 | 18,699 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,120 KB |
testcase_01 | AC | 40 ms
52,352 KB |
testcase_02 | AC | 40 ms
52,608 KB |
testcase_03 | AC | 42 ms
52,480 KB |
testcase_04 | AC | 41 ms
52,736 KB |
testcase_05 | AC | 42 ms
52,608 KB |
testcase_06 | AC | 41 ms
52,608 KB |
testcase_07 | AC | 40 ms
52,992 KB |
testcase_08 | AC | 41 ms
52,900 KB |
testcase_09 | AC | 42 ms
52,864 KB |
testcase_10 | AC | 40 ms
52,096 KB |
testcase_11 | AC | 42 ms
52,864 KB |
testcase_12 | AC | 42 ms
52,480 KB |
testcase_13 | AC | 42 ms
52,736 KB |
testcase_14 | AC | 46 ms
52,480 KB |
testcase_15 | AC | 74 ms
74,496 KB |
testcase_16 | AC | 70 ms
75,672 KB |
testcase_17 | AC | 68 ms
70,784 KB |
testcase_18 | AC | 63 ms
67,584 KB |
testcase_19 | AC | 67 ms
69,760 KB |
testcase_20 | AC | 64 ms
69,376 KB |
testcase_21 | AC | 66 ms
69,376 KB |
testcase_22 | AC | 64 ms
68,352 KB |
testcase_23 | AC | 66 ms
68,736 KB |
testcase_24 | AC | 65 ms
69,760 KB |
testcase_25 | AC | 65 ms
69,760 KB |
testcase_26 | AC | 64 ms
68,864 KB |
testcase_27 | AC | 60 ms
68,608 KB |
testcase_28 | AC | 65 ms
66,688 KB |
testcase_29 | AC | 646 ms
78,300 KB |
testcase_30 | AC | 66 ms
67,840 KB |
testcase_31 | AC | 698 ms
78,336 KB |
testcase_32 | AC | 639 ms
78,336 KB |
testcase_33 | AC | 677 ms
78,772 KB |
testcase_34 | AC | 689 ms
78,384 KB |
testcase_35 | AC | 636 ms
78,080 KB |
testcase_36 | AC | 662 ms
77,824 KB |
testcase_37 | AC | 709 ms
78,720 KB |
testcase_38 | AC | 671 ms
78,848 KB |
testcase_39 | AC | 698 ms
78,208 KB |
testcase_40 | AC | 704 ms
78,464 KB |
testcase_41 | AC | 669 ms
78,548 KB |
testcase_42 | AC | 635 ms
78,720 KB |
testcase_43 | AC | 645 ms
78,080 KB |
testcase_44 | AC | 695 ms
78,720 KB |
testcase_45 | AC | 687 ms
78,936 KB |
testcase_46 | AC | 721 ms
78,500 KB |
testcase_47 | AC | 664 ms
78,592 KB |
testcase_48 | AC | 707 ms
78,380 KB |
testcase_49 | AC | 681 ms
78,436 KB |
testcase_50 | AC | 724 ms
78,464 KB |
testcase_51 | AC | 61 ms
64,256 KB |
testcase_52 | AC | 57 ms
62,848 KB |
testcase_53 | AC | 58 ms
62,464 KB |
testcase_54 | AC | 41 ms
52,992 KB |
testcase_55 | AC | 41 ms
53,376 KB |
testcase_56 | AC | 41 ms
52,992 KB |
testcase_57 | AC | 68 ms
71,168 KB |
testcase_58 | AC | 66 ms
72,320 KB |
testcase_59 | AC | 68 ms
72,192 KB |
ソースコード
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 md = 998244353 # md = 10**9+7 from math import atan2 from bisect import * n = II() xy = LLI(n) rxy = [(atan2(y, x), x, y) for x, y in xy] rxy.sort(key=lambda x: x[0]) rr = [r for r, x, y in rxy] # print(rxy) # print(rr) ans = 0 for i in range(n): r1, x1, y1 = rxy[i] if r1 >= 0: break s1 = atan2(-y1, -x1) l = bisect_right(rr, s1) for j in range(i+1, n): r2, x2, y2 = rxy[j] if x1*y2-y1*x2 == 0: continue if x1*y2-y1*x2 < 0: break s2 = atan2(-y2, -x2) if s2 < 0: r = n else: r = bisect_left(rr, s2) ans += r-l # print(i,j,l,r,ans) print(ans)