Rezultati

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

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

Ocenjevani program (presek.py):
from typing import Tuple

def v_krogu(x, y, x_sr, y_sr, r) -> bool:
    return (x - x_sr) ** 2 + (y - y_sr) ** 2 <= r**2

def v_pravokotniku(x, y, x0, y0, x1, y1) -> bool:
    return x0 <= x and x <= x1 and y0 <= y and y <= y1

def robne_tocke_v_pravokotniku(x_sr, y_sr, r, rectangle) -> Tuple[int, int]:
    x0, y0, x1, y1 = rectangle
    if y0 <= y_sr and y_sr <= y1:
        if x_sr - r <= x0 and x0 <= x_sr + r:
            print(x0, y_sr)
            return True
        if x_sr - r <= x1 and x1 <= x_sr + r:
            print(x1, y_sr)
            return True

    if x0 <= x_sr and x_sr <= x1:
        if y_sr - r <= y0 and y0 <= y_sr + r:
            print(x_sr, y0)
            return True
        if y_sr - r <= y1 and y1 <= y_sr + r:
            print(x_sr, y1)
            return True

    return False

T = int(input())


def main():
    x0, y0, x1, y1, x_sr, y_sr, r = list(map(int, input().strip().split()))

    ogljisca_pravokotnika = [(x0, y0), (x0, y1), (x1, y0), (x1, y1)]

    for ogljisce in ogljisca_pravokotnika:
        if v_krogu(*ogljisce,  x_sr, y_sr, r):
            print(*ogljisce)
            return

    if v_pravokotniku(x_sr, y_sr, x0, y0, x1, y1):
        print(x_sr, y_sr)
        return

    if (robne_tocke_v_pravokotniku(x_sr, y_sr, r, (x0, y0, x1, y1))):
        return

    print("Presek je prazen")

for i in range(T):
    main()