TOPIC
Time limit exceeded
avanessa1 asked 2 years ago
Quando testo, sai o resultado esperado, mas precisa de alguma otimização, já que quanto mando o código retorna o erro de Time limit exceeded. Alguma ajuda?
When I test it, it the output is whats supposed to be, but it need some adjustment, because when i send it to URI it returns to me "Time limit exceeded". Some help? .......................................................................................................................................................................................................................................
T = int(input())
from math import sqrt
fire = [200, 20, 30, 50]
water = [300, 10, 25, 40]
earth = [400, 25, 55, 70]
air = [100, 18, 38, 60]
for t in range(T): w, h, x0, y0 = list(map(int, input().split()))
magia, N, cx, cy = input().split()
dano = 0
if magia == "fire":
raio = fire[int(N)]
D = fire[0]
elif magia == "water":
raio = water[int(N)]
D = water[0]
elif magia == "earth":
raio = earth[int(N)]
D = earth[0]
else:
raio = air[int(N)]
D = air[0]
for L in range(w):
for C in range(h):
distancia = sqrt((int(cx) - x0) ** 2 + (int(cy) - y0) ** 2)
if distancia <= raio:
dano = D
break
x0 += 1
y0 += 1
print(dano)