Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 8,672 MiB 0,000 s OK
#2 11/11 8,586 MiB 0,000 s OK
#3 11/11 8,672 MiB 0,000 s OK
#4 11/11 8,598 MiB 0,000 s OK
#5 11/11 8,590 MiB 0,000 s OK
#6 11/11 8,512 MiB 0,000 s OK
#7 11/11 8,676 MiB 0,000 s OK
#8 11/11 8,523 MiB 0,000 s OK
#9 12/12 8,516 MiB 0,000 s OK

Ocenjevani program (main.py):
tab = input().split(' ')
xa = int(tab[0])
ya = int(tab[1])
xb = int(tab[2])
yb = int(tab[3])

n = int(input())

count = 0

xp = xb-xa
yp = yb-ya

for i in range(n):
    tab = input().split(' ')
    xt = int(tab[0])
    yt = int(tab[1])
    r = int(tab[2])

    if(xp != 0 or yp != 0):
        if(yp == 0):
            xr = 0
            yr = ya-yt
        else:
            xr = (xp * (yt - ya) - yp * (xt - xa)) / (yp + xp*xp/yp)
            yr = -xr * xp / yp

        xk = xt + xr
        yk = yt + yr

        if((xa <= xk <= xb or xb <= xk <= xa) and (ya <= yk <= yb or yb <= yk <= ya)):
            if(xr*xr + yr*yr <= r * r):
                count += 1
        else:
            if ((xt - xa) * (xt - xa) + (yt - ya) * (yt - ya) <= r * r or (xt - xb) * (xt - xb) + (yt - yb) * (yt - yb) <= r * r):
                count += 1
    else:
        if ((xt - xa) * (xt - xa) + (yt - ya) * (yt - ya) <= r * r):
            count += 1

print(count)
'''
0 -1 4 1
7
0 0 1
2 -1 1
5 1 1
-1 -2 1
5 -2 2
2 0 50
6 2 1

0 0 0 0 
5
0 0 1
2 -1 1
5 1 1
-1 -2 1
5 -2 2


0 0 4 2
5
0 0 1
2 -1 1
5 1 1
-1 -2 1
5 -2 2


'''