728x90
반응형
단순 구현 문제이다.
from sys import stdin
for i in range(int(stdin.readline())):
n = int(stdin.readline())
li = [list(map(float, stdin.readline().split())) for n in range(n)]
X = sorted(li, key=lambda x:x[0])
Y = sorted(li, key=lambda x:x[1])
print(f"Case {i+1}:", end=' ')
if n == 1:
area = 0; per = 0
else:
x = X[-1][0]-X[0][0]; y = Y[-1][1]-Y[0][1]
area = x*y
per = 2*(x+y)
print(f"Area {area}, Perimeter {per}")
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 9310번 Arithmetic and Geometric Sums(python) (0) | 2021.02.20 |
---|---|
백준 알고리즘 9299번 Math Tutoring(python) (0) | 2021.02.20 |
백준 알고리즘 9297번 Reducing Improper Fractions(python) (0) | 2021.02.20 |
백준 알고리즘 9295번 주사위(python) (0) | 2021.02.20 |
백준 알고리즘 9288번 More Dice(python) (0) | 2021.02.20 |