Are you local mins such that all neighbours are strictly superior ? (probably not, since it would only find isolated mins)
Then, when you do your BFS, are you looping over all the local minimas ? Are you not doing some redundancy here ?
I mean, once a square has been connected to a minima, I never look at it again.
I think in total, my program runs with O(n log n) for the sort (I think that’s worst case of python sort), and then O(4*n)
(each square can be looked at for all of his four neighbours, and I’m not even sure that’s possible. But maybe my calculation is wrong and it’s higher than that…
I’m really annoyed by not being able to know why we fail (as in wrong answer / delay) as it would help the debugging
I also failed the “Maze 2” validator, but after some trial and error found a test case which I failed.
eulerscheZahl was so kind to add it to the test cases, you might want to have a look at it.
Looking for a hint on where to get started determining the drains. I’ve already read in the data and I can loop through the surface’s points. Just need an idea on what methodology to use to determine drains. Thought about assuming one or more drains then using recursion, but I thought there had to be a more elegant way.
Drains are at minimal values of the surface points. The idea is to pick one of those, and check if it’s enough to drain the whole map. If not, you have to add other drains.
Maze 2 was also the last one for me to pass. A hint to others: I realized my error after reading one of the comments here (about assuming the drains have to be “1”). After doing one round of draining, I was going back to my map and just picking the next place to start draining from, rather than the best place. What’s interesting, I guess, is that this stupid method didn’t fail any of the tests, just only on submission.
Hey guys, any idea what the input for Flat field 2 is? Passing every case except that. My algo is basically forming clusters of equal-valued squares, then adding outflow edges from higher-valued clusters to lower ones, and lastly counting clusters with no outflow edges
Holy shit at first i thought it couldnt handle the Nx1 or the 1xN cases, when actually it died at the 1x1 case. Had to move two lines up a bit to fix it. Im an idiot… Thanks!!!
When i started this one i thought it was “easy” and 10 mins later i had have a solution that made all tests green, but missed 3 validators. I looked into the posts here and figured out, that this on is rated as “very hard” ;), with missing testcases. So i designed a “new” test
5 5
1 1 1 1 1
1 4 4 4 1
1 4 2 4 1
1 4 4 4 1
1 1 1 1 1
with solution 2
after i passed that one, all validators also went green ;).
Thanks @5DN1L for your testcase, I could fix my error: when I created a new group I forgot to update the index of the element in the groups list.
This is the testcase that helped me if that can help you: