Graph, Number Theory, String Hashing Algo added

This commit is contained in:
2023-11-12 19:31:52 +05:30
parent 1abfa41674
commit 6d69543289
10 changed files with 237 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
vector<int> dist(n+1,(int)-1e17);
dist[1]=0;
for(int i = 1 ; i < n ; i++ ){
for(auto& e : g ){
int a,b,w;
tie(a,b,w)=e;
dist[b]=max(dist[b],dist[a]+w);
}
}
for(auto& e : g ){
int a,b,w;
tie(a,b,w)=e;
if( dist[b] < dist[a] + w ){
cycle[b]=true;
}
}