Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 8,734 MiB 0,000 s OK
#2 11/11 8,730 MiB 0,000 s OK
#3 11/11 8,719 MiB 0,000 s OK
#4 11/11 8,715 MiB 0,000 s OK
#5 11/11 8,723 MiB 0,000 s OK
#6 11/11 8,734 MiB 0,000 s OK
#7 11/11 8,719 MiB 0,000 s OK
#8 11/11 8,730 MiB 0,000 s OK
#9 12/12 8,730 MiB 0,000 s OK

Ocenjevani program (plez.py):
import sys, math
sys.setrecursionlimit(10**9)


#sys.stdin = open("b.in")

inp = sys.stdin

Xa, Ya, Xb, Yb= map(float,inp.readline().split())

N = int(inp.readline())

ss = 0
eps = 10**-5
if Xa != Xb:
    k = (Yb-Ya)/(Xb-Xa)
    n = Yb - k*Xb

    for j in range(N):
        P, Q, R = map(float,inp.readline().split())
        R +=(10**-4)/2
        a = 1 + k*k
        b = -2*P + 2*k*n - 2*Q*k
        c = P*P + n*n + Q*Q - 2*Q*n - R*R

        D = b*b - 4*a*c
        if D >= 0:
            x1 = (-b - D**0.5)/2/a
            x2 = (-b + D**0.5)/2/a
            #print(x1, x2)
            Xaa, Xbb = min(Xa, Xb), max(Xa, Xb)
            if Xaa <= x1:
                if Xbb +eps >= x1:
                    ss += 1
            elif Xaa <= x2:
                ss += 1
            else:
                pass



else:
    Ya, Yb = min(Ya, Yb), max(Ya, Yb)
    for j in range(N):
        P, Q, R = map(float,inp.readline().split())
        R += (10 ** -4) / 2
        if P-R <= Xa <= P+R :
            iz = R*R - (Xa-P)**2
            if iz >= 0:
                iiz = iz**0.5
                amin = Q - iiz
                amax = Q + iiz
            if Yb >= amax:
                if Ya <= amax:
                    ss += 1
            else:
                if Ya  >= amin:
                    ss += 1
                else:
                    if Yb >= amin:
                        ss += 1

print(ss)