목차

Parallelogram Counting

ps
링크acmicpc.net/…
출처BOJ
문제 번호6744
문제명Parallelogram Counting
레벨플래티넘 4
분류

기하학

시간복잡도O(t*n^2)
인풋사이즈t<=10, n<=1000
사용한 언어Python 3.13
제출기록137228KB / 2124ms
최고기록2124ms
해결날짜2025/02/19

풀이

코드

"""Solution code for "BOJ 6744. Parallelogram Counting".

- Problem link: https://www.acmicpc.net/problem/6744
- Solution link: http://www.teferi.net/ps/problems/boj/6744

Tags: [geometry]
"""

import collections
import itertools
import sys
from teflib import psutils


@psutils.run_n_times
def main():
    N = int(sys.stdin.readline())
    P = [[int(x) for x in sys.stdin.readline().split()] for _ in range(N)]

    pair_by_center = collections.Counter(
        (px + qx, py + qy)
        for (px, py), (qx, qy) in itertools.combinations(P, 2)
    )
    answer = sum(c * (c - 1) // 2 for c in pair_by_center.values())

    print(answer)


if __name__ == '__main__':
    main()