Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kumkvat-2018 Presek Python 3 100/100OK 04. okt '18 @ 18:23

Test Točke Porabljen spomin Porabljen čas Status
#1 100/100 8,711 MiB 0,000 s OK

Ocenjevani program (presek.py):
def dist(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y2 - y1) ** 2) ** (1 / 2)

def presek(x1, y1, x2, y2, s1, s2, r):
    sx, sy = (x1 + x2)/2, (y1 + y2)/2
    if (s1 >= x1 and s1 <= x2) and (s2 >= y1 and s2 <= y2):
        return s1, s2
    d_sredisci = ((s1 - sx)**2 + (s2 - sy)**2)**(1/2)
    if d_sredisci <= r:
        return sx, sy
    if s2 < y2 and s2 > y1:
        if s1 < x1:
            if x1 - s1 > r:
                return
            else:
                return x1, s2
        elif s1 > x2:
            if s1 - x2 > r:
                return
            else:
                return x2, s2
    if s1 < x2 and s1 > x1:
        if s2 < y1:
            if y1 - s2 > r:
                return
            else:
                return s1, y1
        elif s2 > y2:
            if s2 - y2 > r:
                return
            else:
                return s1, y2

    if (s1 <= x1 and s2 <= y1) and dist(s1, s2, x1, y1) <= r:
        return x1, y1
    elif (s1 <= x1 and s2 >= y2) and dist(s1, s2, x1, y2) <= r:
        return x1, y2
    elif (s1 >= x2 and s2 <= y1) and dist(s1, s2, x2, y1) <= r:
        return x2, y1
    elif (s1 >= x2 and s2 >= y2) and dist(s1, s2, x2, y2) <= r:
        return x2, y2
    return

n = int(input().strip())

for i in range(n):
    x1, y1, x2, y2, s1, s2, r = map(int, input().strip().split(' '))
    p = presek(x1, y1, x2, y2, s1, s2, r)
    if p:
        print('{} {}'.format(p[0], p[1]))
    else:
        print('Presek je prazen')