/******************************************************* * Copyright (C) 2015 Haotian Wu * * This file is the solution to the question: * https://www.hackerrank.com/challenges/jack-goes-to-rapture * * Redistribution and use in source and binary forms are permitted. *******************************************************/ #include #include #include #include #include #include #include #include #include #include using namespace std; // This problem is very interesting. The problem is not difficult, but it really costs me half hour to think of a solution. // Clearly, the question is asking to find a path, such that the max weight edge in the path is minimum. // We could binary search the answer, and check if we could reach the destination only using the edges less or equal to the value. vector > adj[50001]; int main() { int n,m; scanf("%d %d",&n,&m); for (int i=0;i 10000000) printf("NO PATH EXISTS\n"); else printf("%d\n",be); }