Comments

Input — n = 109

Correct Output — 999

Your Output — 9

Inside the solve function --> you are creating a self loop => which may cause both TLE and Wrong answer

graph[u].push_back(Edge(v, b)); graph[u].push_back(Edge(u, b)); --> v must be there

I think it should get accepted, feeling bad for the typo..

It worked for me with just some slight modification - At line 52, 53 and 69, 71 --> rest the whole algorithm will be normal djikstra

You can check — My submission