June Circuits-19 Minimum Matrix

I recently came across this problem on hackerearth. How would we solve this ? This has relative scoring . Now i have seen the top submissions but none of them are less than a 1000 lines of code and it is difficult figuring out what have they done. Could someone provide and insight on this?
Problem Link-Minimum Matrix

1 Like