This repository has been archived on 2022-01-12. You can view files and clone it, but cannot push or open issues or pull requests.
USACO-Demo/triangles.py
2020-07-25 15:17:26 -05:00

41 lines
784 B
Python

with open("triangles.in", "r") as fin:
L = list(fin)
N = int(L[0])
X = []
Y = []
for i in range(1, N + 1):
x, y = map(int, L[i].split())
X.append(x)
Y.append(y)
ans = 0
for i in range(0, N):
for j in range(i + 1, N):
for k in range(j + 1, N):
base = 0
height = 0
if X[i] == X[j]:
height = abs(Y[j] - Y[i])
elif X[j] == X[k]:
height = abs(Y[k] - Y[j])
elif X[k] == X[i]:
height = abs(Y[i] - Y[k])
else:
continue
if Y[i] == Y[j]:
base = abs(X[j] - X[i])
elif Y[j] == Y[k]:
base = abs(X[k] - X[j])
elif Y[k] == Y[i]:
base = abs(X[i] - X[k])
else:
continue
if base*height > ans: ans = base*height
with open("triangles.out", "w") as fout:
fout.write(str(ans))