Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kjejenovictk-2018 Fruit Ninja Python 3 100/100OK 13. okt '18 @ 12:16

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 8,609 MiB 0,000 s OK
#2 11/11 8,598 MiB 0,000 s OK
#3 11/11 8,676 MiB 0,000 s OK
#4 11/11 8,621 MiB 0,000 s OK
#5 11/11 8,641 MiB 0,000 s OK
#6 11/11 8,777 MiB 0,000 s OK
#7 11/11 8,699 MiB 0,000 s OK
#8 11/11 8,625 MiB 0,000 s OK
#9 12/12 8,637 MiB 0,000 s OK

Ocenjevani program (fruitNinja.py):
import sys
import math

sys.setrecursionlimit(10**9)

data = sys.stdin.readlines()

#data = open("fruitNinja.txt").readlines()
xa,ya,xb,yb = list(map(float,data[0].strip().split()))
#xa,ya,xb,yb = [3,3,0,0]
#N = 1
N = int(data[1].strip())
koliko = 0
if xa>xb:
    xc = xa
    yc = ya
    xa = xb
    ya = yb
    xb = xc
    yb = yc
#print(xa,ya,xb,yb)
for i in range(2,N+2):
    P,Q,R = list(map(float,data[i].strip().split()))
    if (xb-xa)*(P-xa) + (yb-ya)*(Q-ya) > 0 and (xa-xb)*(P-xb) + (ya-yb)*(Q-yb)>0:
        premica = [xa-xb,ya-yb]
        dolz1 = math.sqrt(premica[0]*premica[0]+premica[1]*premica[1])
        vektor = [xa-P,ya-Q]
        dolz2 = math.sqrt(vektor[0]*vektor[0]+vektor[1]*vektor[1])
        sinus = abs(premica[0]*vektor[1] - vektor[0]*premica[1])/(dolz1*dolz2)
        if dolz2*sinus <=R:
            koliko+=1
            continue
    if (xa-P)*(xa-P) + (ya-Q)*(ya-Q) <= R*R or (xb-P)*(xb-P) + (yb-Q)*(yb-Q) <= R*R:
        koliko+=1
        continue
    #print(P,Q,R)

print(koliko)