목차

직각 삼각형

ps
링크acmicpc.net/…
출처BOJ
문제 번호3000
문제명직각 삼각형
레벨실버 1
분류

기하학

시간복잡도O(n)
인풋사이즈n<=100,000
사용한 언어Python 3.13
제출기록53760KB / 172ms
최고기록100ms
해결날짜2025/02/18

풀이

코드

"""Solution code for "BOJ 3000. 직각 삼각형".

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

Tags: [geometry]
"""

import collections
import sys


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

    x_counter = collections.Counter(x for x, y in X_and_Y)
    y_counter = collections.Counter(y for x, y in X_and_Y)
    answer = sum(
        (x_counter[x_i] - 1) * (y_counter[y_i] - 1) for x_i, y_i in X_and_Y
    )

    print(answer)


if __name__ == '__main__':
    main()