Guest User

Untitled

a guest
Dec 14th, 2019
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cin >> n >> e >> source >> sink;
  2. for (int i = 0; i < e; i++) cin >> A[i] >> B[i] >> C[i];
  3. for (int i = 1; i <= n; i++) dist[i] = INF;
  4. dist[source] = 0;
  5. for (int i = 0; i < n; i++)
  6. {
  7. for (int j = 0; j < e; j++)
  8. {
  9. dist[A[j]] = min(dist[A[j]], dist[B[j]] + C[j]);
  10. dist[B[j]] = min(dist[B[j]], dist[A[j]] + C[j]);
  11. }
  12. }
  13. cout << dist[sink];
RAW Paste Data