본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 9298번 Ant Entrapment

by 현장 2025. 1. 16.

-Code

for t in range(int(input())):
    n = int(input())
    x_list, y_list = [], []

    for _ in range(n):
        x, y = map(float, input().split())
        x_list.append(x)
        y_list.append(y)

    x_max, x_min = max(x_list), min(x_list)
    y_max, y_min = max(y_list), min(y_list)
    x_len = x_max - x_min
    y_len = y_max - y_min

    print(f"Case {t + 1}: Area {x_len * y_len}, Perimeter {(x_len + y_len) * 2}")