Threads Per Block

Day 6 of Advent of Code

Fuck me, this was brutal. Part 1 was a challenge and part 2 was straight up a nightmare. I found a relatively efficient brute-force solution but I wonder if it could have been done better. There is a graph-based soln someone posted which looks pretty good. The claim is O(n*m). To be seen.