Submission #68349046
Source Code Expand
from collections import Counter, defaultdict from itertools import combinations from math import gcd N = int(input()) XY = [] for _ in range(N): x, y = map(int, input().split()) XY.append((x, y)) XY.sort() countl = Counter() countd = defaultdict(lambda: defaultdict(int)) SIZE = 1 << 30 def conv(x, y): return SIZE * x + y for (x1, y1), (x2, y2) in combinations(XY, 2): x = x2 - x1 y = y2 - y1 if x == 0: countl[conv(0, 1)] += 1 countd[conv(0, 1)][y * y] += 1 elif y == 0: countl[conv(1, 0)] += 1 countd[conv(1, 0)][x * x] += 1 else: d = x * x + y * y g = abs(gcd(x, y)) x //= g y //= g countl[conv(x, y)] += 1 countd[conv(x, y)][d] += 1 ans = 0 dup = 0 for v, t in countl.items(): ans += t * (t - 1) // 2 for t2 in countd[v].values(): dup += t2 * (t2 - 1) // 2 print(ans - dup // 2)
Submission Info
Submission Time | |
---|---|
Task | E - Trapezium |
User | mo12412 |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 475 |
Code Size | 967 Byte |
Status | AC |
Exec Time | 2799 ms |
Memory | 1024240 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 475 / 475 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-01.txt, 00-sample-02.txt |
All | 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-01.txt | AC | 68 ms | 77116 KiB |
00-sample-02.txt | AC | 68 ms | 77000 KiB |
01-01.txt | AC | 67 ms | 76892 KiB |
01-02.txt | AC | 145 ms | 121004 KiB |
01-03.txt | AC | 2213 ms | 811124 KiB |
01-04.txt | AC | 1039 ms | 481736 KiB |
01-05.txt | AC | 2696 ms | 1024156 KiB |
01-06.txt | AC | 2793 ms | 1024240 KiB |
01-07.txt | AC | 750 ms | 256972 KiB |
01-08.txt | AC | 710 ms | 256800 KiB |
01-09.txt | AC | 705 ms | 253944 KiB |
01-10.txt | AC | 536 ms | 195392 KiB |
01-11.txt | AC | 490 ms | 176496 KiB |
01-12.txt | AC | 2542 ms | 902084 KiB |
01-13.txt | AC | 2587 ms | 898776 KiB |
01-14.txt | AC | 2175 ms | 575100 KiB |
01-15.txt | AC | 2211 ms | 574768 KiB |
01-16.txt | AC | 2707 ms | 1021220 KiB |
01-17.txt | AC | 2745 ms | 1020672 KiB |
01-18.txt | AC | 2215 ms | 795748 KiB |
01-19.txt | AC | 2209 ms | 795672 KiB |
01-20.txt | AC | 2276 ms | 795340 KiB |
01-21.txt | AC | 2310 ms | 815236 KiB |
01-22.txt | AC | 2672 ms | 1022812 KiB |
01-23.txt | AC | 2536 ms | 807792 KiB |
01-24.txt | AC | 2709 ms | 1022928 KiB |
01-25.txt | AC | 2799 ms | 921576 KiB |
01-26.txt | AC | 2760 ms | 1023756 KiB |