Hello codeforces community!
Since I already have top-2000 and top-200 t-shirts from previous participations and because I don't wanna spent another ~40$ to get it delivered to Russia (especially with current ruble situation :/) I decided to give it to the first person who will hack my solution to the Shortest Routes I problem from CSES.
The solution is based on SPFA algorithm which in theory could run in $$$O(nm)$$$ as Ford-Bellman does, but in practice it is quite fast, sometimes even faster then Dijkstra.
Give it a try!
UPD: Faisal-Saqib was the the first to hack, congratulations! Sent you the code in DMs.
is it still valid or did someone win ?
Valid. I will announce the winner when we'll have one)
i hacked it check it now
Share the testcase and idea behind it please.
just kidding sorry i am noob
Here is your t-shirt then
I have hacked your solution. https://cses.fi/problemset/hack/1671/result/33262/
The explanation is that your code does kinda bfs, but you can add a vertex again, and that is the catch.
I would have been alot easier if you didn't randomly shuffle the adjacent list(also the MAGIC thing).We kind of use a little bit probability. We make the graph like this from every vertex i put edge to next k=5 (from i+2 , .. n), vertexes with weight 2*(n-i). At the end add egdes i to i+1 with weight 1. First it visits all vertex with wrong distance with some probability,then it visits them with correct once.
I tried some value for k but the worst I found was for k=5.
Pls give me sensei ,it will motivate me to code more and be gm one day
different hack: https://cses.fi/problemset/hack/1671/result/33264/
The testcase is basically the first result on google: https://stackoverflow.com/a/76249282 which is already robust against shuffling edges. The only thing that needs to be changed is to handle
MAGIC
. This can be done by adding new edges to dummy vertices that just avoid swapping vertices to the front:This is a working testcase. However, you will realize that this problem does not allow $$$0$$$ edges, the code above already handles this. (just increase zero edges and decrease non zero edges properly).