Mowing the Field 2016 Bronze Solution

Solution - Mowing the Field (USACO Bronze 2016 January) (python solution)

What does the line visits = {1000 * 1000 + 1000: 0} do? When I print it out, it says visits = {1001000: 0} .

Also, if direction is North, why do we change dirX by 1? Shouldn’t we change dirY by 1, since it moves up in the y direction?

Thanks!

It initializes a dictionary with a single (key, value) pair. Here, the key is 1000 * 1000 + 1000 = 1001000.

You’re right. The answer doesn’t change if you swap N/S with E/W though.

1 Like