https://www.acmicpc.net/problem/9063
9063번: 대지
첫째 줄에는 점의 개수 N (1 ≤ N ≤ 100,000) 이 주어진다. 이어지는 N 줄에는 각 점의 좌표가 두 개의 정수로 한 줄에 하나씩 주어진다. 각각의 좌표는 -10,000 이상 10,000 이하의 정수이다.
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
def sol(xs, ys):
if len(list(set(xs))) == 1 or len(list(set(ys))) == 1:
return 0
else:
return (max(xs) - min(xs)) * (max(ys) - min(ys))
if __name__ == '__main__':
n = int(input())
xs = []
ys = []
for i in range(n):
x, y = map(int, input().split())
xs.append(x)
ys.append(y)
print(sol(xs, ys))
|
cs |
직사각형이 만들어 질려면.. 조건은 구하기 어렵습니다...
따라서
모든 점의 x좌표가 같거나 혹은 모든점의 y좌표가 같으면 직사각형이 만들어 지지 않는 조건을 이용함
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3028. Ant on the Boundary (0) | 2024.02.06 |
---|---|
leetcode 3019. Number of Changing Keys (0) | 2024.02.05 |
leetcode 3014. Minimum Number of Pushes to Type Word I (1) | 2024.01.23 |
leetcode 3010. Divide an Array Into Subarrays With Minimum Cost I (0) | 2024.01.23 |
leetcode 645. Set Mismatch (0) | 2024.01.22 |
댓글