Skip to content

Instantly share code, notes, and snippets.

@maskmanlucifer
Created June 10, 2021 13:08
Show Gist options
  • Save maskmanlucifer/4ff93acb5c5ab74a1a7bed61e0f5e034 to your computer and use it in GitHub Desktop.
Save maskmanlucifer/4ff93acb5c5ab74a1a7bed61e0f5e034 to your computer and use it in GitHub Desktop.
>> Floyd Warshall
>>> Reources:
T-1: https://www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/
T-2: https://www.youtube.com/watch?v=oNI0rf2P9gE
T-3: https://cp-algorithms.com/graph/all-pair-shortest-path-floyd-warshall.html
>>> Implementation:
ll dp[N][N];
for(ll k=1;k<=v;k++)
{
for(ll i=1;i<=v;i++)
{
for(ll j=1;j<=v;j++)
{
dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
}
}
}
>>> Problems:
Problem-1: https://codeforces.com/problemset/problem/295/B
Solution : https://codeforces.com/contest/295/submission/87034220
Problem-2: https://codeforces.com/contest/189/problem/D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment