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()