Shortest path in a unweighted graph(if many then lexicographically smallest)

Revision en1, by Zain-khatib, 2020-05-02 17:33:32

I tried to solve this problemproblem using BFS on priority queue with a custom comparator ,but getting WA ,and I really wanna know if the main idea is wrong or there is something in the code code ~~~~~ struct Compare { bool operator()(pair<string, int> const& p1, pair<string, int> const& p2) { if (p1.first.length() == p2.first.length()) return p1.first > p2.first; return p1.first.length() > p2.first.length(); } }; ~~~~~

Tags #graph, #bfs, lexicography

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English Zain-khatib 2020-05-02 17:36:26 17 Tiny change: 'n\n~~~~~\nYour code here...\nstruct C' -> 'n\n~~~~~\n\nstruct C'
en3 English Zain-khatib 2020-05-02 17:36:10 241
en2 English Zain-khatib 2020-05-02 17:35:27 249
en1 English Zain-khatib 2020-05-02 17:33:32 597 Initial revision (published)