# Help on Blocked Billboard

## Problem Info

Blocked Billboard: https://usaco.org/index.php?page=viewproblem2&cpid=759

## Question

Why do all test cases pass at a very short time except 9 and 10? (When submitting on usaco.org, test cases 9 and 10 run at ~3500 ms.)

## What I’ve Tried

I switched from using a list to a set, which made it run just under the time limit on usaco.org on cases 9 and 10, but I still want to know why my program still runs for such a long time with these cases.

## My Work

``````squares = set()

fin = open("billboard.in", "r")
fout = open("billboard.out", "w")

for i in range(3):
x1, y1, x2, y2 = map(int, fin.readline().split())

if i == 0 or i == 1:
for j in range(x1, x2):
for k in range(y1, y2):
else:
for j in range(x1, x2):
for k in range(y1, y2):
if (j,k) in squares:
squares.remove((j, k))

fout.write(str(len(squares)))
``````

I create an empty set of visible squares. For the first two input lines (which are the billboards), I add the coordinates inside/on the billboards to my `squares` set as they are visible. For the last input line (which is the truck), I remove all of the coordinates inside/on the truck from the `squares` list if they exist, as they are no longer visible. Finally, I write the number of visible squares to `billboard.out`.

Python is slow

You can download the test cases yourself to check what the last two tests are.