7236 vector<unordered_map<int, int>> g(n + 1);
7237 vector reachable(n + 1,
false);
7238 vector shortest(n + 1, 0x3f3f3f);
7239 for(
int i = 0; i < m; i++) {
7247 g[x][y] = min(g[x][y], z);
7251 unordered_set<int> us;
7255 reachable[1] =
true;
7257 int node = q.front();
7260 for(
auto [next_node, d]: g[node]) {
7261 reachable[next_node] =
true;
7262 if(shortest[next_node] > shortest[node] + d) {
7263 shortest[next_node] = shortest[node] + d;
7264 if(!us.contains(next_node)) {
7266 us.insert(next_node);
7272 cout <<
"impossible";
7274 cout << shortest[n];