結果
問題 |
No.947 ABC包囲網
|
ユーザー |
![]() |
提出日時 | 2020-03-21 20:23:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 593 ms / 2,000 ms |
コード長 | 762 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 44,032 KB |
最終ジャッジ日時 | 2024-12-23 13:04:09 |
合計ジャッジ時間 | 32,628 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) XY = np.array(read().split(), np.int64) X = XY[::2] Y = XY[1::2] g = np.abs(np.gcd(X, Y)) Xd = X // g Yd = Y // g key = (Xd << 32) + Yd total = N * (N - 1) * (N - 2) // 6 ng0 = 0 ng1 = 0 ng2 = 0 ng3 = 0 ng4 = 0 for x, y, k in zip(X, Y, key): n = np.count_nonzero(X * y - Y * x > 0) same = np.count_nonzero(key == k) opp = np.count_nonzero(key == -k) ng0 += n * (n - 1) // 2 ng1 += (same - 1) * n ng2 += opp * (N - same - opp) ng3 += (same - 1) * opp ng4 += (same - 1) * (same - 2) // 2 ng = ng0 + (ng1 + ng2 + ng3) // 2 + ng4 // 3 print(total - ng)