The idea behind my solution is that in the optimal path you don't enter any vertex after the first time it can be entered + n. I wonder if there is a proof that this works correctly or a way to disprove it, but I'm having trouble finding either. If anyone is interested, please help.









I did the same with +5050 instead of +n. I summon the hack gods to sacrifice my solution https://mirror.codeforces.com/contest/2122/submission/329873748
i did the same but with degree of the vertex + 4 instead, had it been exactly degree of the vertex i could've hacked it but not sure how the + goes
hacked.
I would like to reply with the same message to Pox_2000 as he expressed a similar idea below: You can enter a branch of one node in the shortest path and then move back and forth in the branch many times until you can move to the next node in the shortest path. Here, we can add useless edges to make sure we have to stay in the branch for at least $$$\mathcal O(\sqrt{n})$$$ seconds (I don't know if there exists a straightforward construction that makes it $$$\mathcal O(n)$$$ so I only submitted one such $$$\mathcal O(\sqrt{n})$$$ test case). In contrast, the degree of nodes in the branch is $$$\mathcal O(1)$$$.
I believe that $$$+n$$$ is correct (I implemented the same thing in contest), but I'm looking for a formal proof too.
I’m pretty sure you can reduce $$$n$$$ to $$$deg(v)$$$ of the vertex you are on (correct me if I forgot an additive constant).
The main logic is this: say instead of moving in a loop for $$$d$$$ time from $$$v$$$ back to $$$v$$$, you wait for some seconds $$$t$$$ before selecting the edge and moving away. Since the selection operation cycles every $$$deg(v)$$$ seconds, you can enforce $$$t \lt deg(v)$$$ seconds. So even if you loop around without stopping, if $$$t \lt d$$$ then this is never going to be optimal since you can cut the loop off and just wait for $$$t$$$ seconds.
I made the same assumption and my solution has been helpfully hacked. I believe the same test should work for your solution as well, here's my submission: 329875868
Unfortunately, my solution gives the correct answer to this test