Help this USACO problem
I'm trying to solve this problem about 3 days.I understood solution but solution doesn't say how to do that trick.
Leetcode Weekly 498 Solution Discussion