Exemple #1
0
    def test_vertical_non_intersecting_slanted2(self):
        # Assume
        vt = Tarp(Point(4, 3), Point(4, 4))
        t = Tarp(Point(1, 2), Point(4, 4))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertFalse(intersect)
Exemple #2
0
    def test_intersecting_perpendicular(self):
        # Assume
        vt = Tarp(Point(0, 0), Point(1, 1))
        t = Tarp(Point(1, 0), Point(0, 1))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertTrue(intersect)
Exemple #3
0
    def test_vertical_intersecting_negative_slanted3(self):
        # Assume
        vt = Tarp(Point(10, 10), Point(10, 11))
        t = Tarp(Point(25, 5), Point(0, 15))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertTrue(intersect)
Exemple #4
0
    def test_vertical_intersecting_negative_slanted(self):
        # Assume
        vt = Tarp(Point(3, 2), Point(3, 3))
        t = Tarp(Point(5, 1), Point(2, 3))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertTrue(intersect)
Exemple #5
0
    def test_vertical_non_intersecting_negative_slanted2(self):
        # Assume
        vt = Tarp(Point(10, 11), Point(10, 12))
        t = Tarp(Point(25, 5), Point(0, 15))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertFalse(intersect)
Exemple #6
0
    def test_non_intersecting_parallel(self):
        # Assume
        vt = Tarp(Point(0, 0), Point(1, 1))
        t = Tarp(Point(1, 0), Point(2, 1))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertFalse(intersect)
Exemple #7
0
    def test_vertical_intersecting_slanted(self):
        # Assume
        vt = Tarp(Point(3, 3), Point(3, 4))
        t = Tarp(Point(1, 2), Point(4, 4))

        # Action
        intersect = t.intersect(vt)

        # Assert
        self.assertTrue(intersect)
Exemple #8
0
    def test_punctures7(self):
        # Assume
        t0 = Tarp(Point(4, 2), Point(1, 3))
        t1 = Tarp(Point(6, 1), Point(1, 4))
        v = Vineyard(3, 4, [t0, t1])

        # Action
        minimum_punctures = v.punctures()

        # Assert
        self.assertEqual(1, minimum_punctures)
Exemple #9
0
    def test_punctures5(self):
        # Assume
        t0 = Tarp(Point(8, 2), Point(5, 3))
        t1 = Tarp(Point(10, 2), Point(5, 6))
        t2 = Tarp(Point(9, 2), Point(4, 4))
        v = Vineyard(2, 3, [t0, t1, t2])

        # Action
        minimum_punctures = v.punctures()

        # Assert
        self.assertEqual(0, minimum_punctures)
Exemple #10
0
    def test_punctures(self):
        # Assume
        t0 = Tarp(Point(4, 2), Point(1, 3))
        t1 = Tarp(Point(6, 2), Point(2, 5))
        t2 = Tarp(Point(5, 2), Point(0, 4))
        v = Vineyard(3, 5, [t0, t1, t2])

        # Action
        minimum_punctures = v.punctures()

        # Assert
        self.assertEqual(1, minimum_punctures)
Exemple #11
0
    def test_punctures6(self):
        # Assume
        t0 = Tarp(Point(4, 2), Point(1, 3))
        t1 = Tarp(Point(6, 2), Point(1, 6))
        t2 = Tarp(Point(5, 2), Point(0, 4))
        t3 = Tarp(Point(3, 1), Point(7, 2))
        v = Vineyard(2, 3, [t0, t1, t2, t3])

        # Action
        minimum_punctures = v.punctures()

        # Assert
        self.assertEqual(0, minimum_punctures)
Exemple #12
0
    def test_punctures3(self):
        # Assume
        t0 = Tarp(Point(32, 50), Point(12, 60))
        t1 = Tarp(Point(30, 60), Point(8, 70))
        t2 = Tarp(Point(25, 70), Point(0, 80))
        t3 = Tarp(Point(15, 30), Point(28, 40))
        t4 = Tarp(Point(5, 20), Point(14, 25))
        v = Vineyard(10, 20, [t0, t1, t2, t3, t4])

        # Action
        minimum_punctures = v.punctures()

        # Assert
        self.assertEqual(2, minimum_punctures)
Exemple #13
0
    def update(self, t: Tarp):
        xl, xr = t.sorted_xs()

        if t.slope() > 0:
            i = xl + 1
            delta = 1
        else:
            i = xr - 1
            delta = -1

        for x in range(xr - xl):
            self.punctures[i] = min(self.punctures[i] + 1,
                                    self.punctures[i - delta])
            i = i + delta
Exemple #14
0
import sys
from rainfall.core.Point import Point
from rainfall.core.Tarp import Tarp
from rainfall.core.Vineyard import Vineyard

# Uncomment the next two lines if you want to use a file as standard input
in_path = "C:/Users/kuby/Downloads/icpc2019data/F-directingrainfall/secret-10-matthias.in"
sys.stdin = open(in_path, "r")

l, r, n = tuple([int(n) for n in input().split(" ")])

tarps = []
max_x = 0

for i in range(n):
    lx, ly, hx, hy = tuple([int(i) for i in input().split(" ")])
    max_x = max(max_x, lx, hx)
    tarps.append(Tarp(Point(lx, ly), Point(hx, hy)))

vineyard = Vineyard(l, r, tarps, max_x)
print(vineyard.punctures())