Rezultati

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

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

Ocenjevani program (presek.py):
import sys

data = sys.stdin



#data = open("test1.in")
N = int(data.readline())
def dist(x1,y1,x2,y2):
    return ((x1 - x2)**2 + (y1 - y2)**2)**(0.5)

def check(x1,y1,x2,y2,xk,yk,r):

    # center je v pravokotniku
    if xk<=x2 and xk>=x1 and yk<=y2 and yk>=y1:
        print( "{} {}".format(xk, yk))
        return

    if xk>x1 and xk < x2:
        #nad pravokotnikom
        if yk > y2:
            if yk - r <= y2:
                print("{} {}".format(xk, y2))
                return
            else:
                print("Presek je prazen")
                return
        #pod
        if yk < y1:
            if yk + r >= y1:
                print("{} {}".format(xk, y1))
                return
            else:
                print("Presek je prazen")
                return

    if yk<y2 and yk > y1:
        if xk < x1:
            if xk + r >=x1:
                print("{} {}".format(x1, yk))
                return
            else:
                print("Presek je prazen")
                return
        if xk > x2:
            if xk - r <= x2:
                print("{} {}".format(x2, yk))
                return
            else:
                print("Presek je prazen")
                return


    if dist(x1,y1,xk,yk) <=r:
        print("{} {}".format(x1,y1))
        return
    if dist(x1,y2,xk,yk) <= r:
        print("{} {}".format(x1, y2))
        return
    if dist(x2,y1,xk,yk) <=r:
        print("{} {}".format(x2,y1))
        return
    if dist(x2,y2,xk,yk)<=r:
        print("{} {}".format(x2,y2))
        return



    print("Presek je prazen")


for _ in range(N):
    case = list(map(int, data.readline().strip().split(" ")))
    check(case[0], case[1], case[2], case[3], case[4], case[5], case[6])