Should I Use Matrices for Cow Tipping (Bronze)?

I’m confused on Cow Tipping (January 2017). Instead of using a matrix like other solutions, I just opted for using the extend function. Is this why my code fails on some cases? And can I do this in the future?

f = open('cowtip.in', 'r')
n = int(f.readline())
cows = []
for _ in range(n):
    cows.extend(list(map(int, f.readline()[:-1])))
t = 0
while 1 in cows:
    farthest_cow = n**2 - list(reversed(cows)).index(1)
    for i in range(farthest_cow):
        if cows[i] == 0:
            cows[i] = 1
        else:
            cows[i] = 0
    t += 1
f = open('cowtip.out', 'w')
f.write(str(t))

I’ve already looked at the solutions, but the test cases I fail on are quite large in size and would probably take a long time to debug through.

Additionally, here’s my USACO status so far:

https://forum.usaco.guide/t/how-to-ask-for-help-on-a-problem/338/2