Hi guys,
I was looking for min-cost-max-flow problems and found this
http://www.spoj.com/problems/GREED/
I coded solution, submitted it and received AC with about 20s time. Unfortunately, there are accepted runs with time less than 2s.
I guess my solution in so slow because of my poor implementation of the algorithm.
Can somebody take a look on my solution and tell me what I'm doing wrong?
UPD: I've implemented Dijkstra's algo with potentials, and ... accepted this problem with 40s. Twice slower! I don't know, what's wrong with me? :/
UPD2: Changed algorithm to use Dijkstra for sparse graph. However, received AC with ~40s. OMG, WHAT IS WRONG WITH MY CODE?
Algo using Dijkstra for sparse graphs
Thanks in advance.