Skip to content

Instantly share code, notes, and snippets.

View lsiddiqsunny's full-sized avatar
🎯
Focusing

Latif Siddiq Sunny lsiddiqsunny

🎯
Focusing
View GitHub Profile
@lsiddiqsunny
lsiddiqsunny / Minimum spanning tree-prim .cpp
Last active September 20, 2017 18:32
Prim's algorithm implementation for minimum spanning tree.
#include<bits/stdc++.h>
using namespace std;
#define mx 50005
typedef pair<long long int,int> PII;
vector<PII>g[mx];
bool marked[mx];
long long prim(int x)
{
priority_queue<PII, vector<PII>, greater<PII> > Q;
int y;
@lsiddiqsunny
lsiddiqsunny / Krushkal's Minimum spanning tree.cpp
Last active September 4, 2017 19:32
Krushkal algorithm implementation for Minimum spanning tree
#include<bits/stdc++.h>
using namespace std;
#define mx 500005
int id[mx],n,m;
pair <long long, pair<int, int> > p[mx];
void initialize()
{
for(int i = 0; i < mx; ++i)
id[i] = i;
@lsiddiqsunny
lsiddiqsunny / articulationpoint.cpp
Created September 5, 2017 08:08
Implementation for finding articulation
#include<bits/stdc++.h>
using namespace std;
#define mx 100005
vector<int>g[mx];
int visited[mx];
bool articulation[mx];
int low[mx],d[mx],parent[mx];
int t;
@lsiddiqsunny
lsiddiqsunny / scc.cpp
Last active September 7, 2017 05:57
Implementation for finding strongly connected components
#include<bits/stdc++.h>
#define mx 50005
using namespace std;
vector<int>g[mx],rg[mx],path,newg[mx];
int visited[mx],scc[mx];
int numscc;
void dfs1(int s)
#include<bits/stdc++.h>
using namespace std;
#define mx 200005
vector<int>g[mx];
vector<int>ans; //storing topological sorted vertex
int indegree[mx];
/*int visited[mx];
#include<bits/stdc++.h>
using namespace std;
#define mx 200005
vector<int>g[mx];
int visited[mx];
stack<int>s;
void dfs(int u)
{
visited[u]=1;
#include<bits/stdc++.h>
using namespace std;
#define MAX 2000005
class Graph
{
vector<int>g[MAX];
int color[MAX];
long long in[MAX];
long long out[MAX];
int edges;
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pb push_back
#define INF 0x7fffffff
#define sz 100005
priority_queue<pii,vector<pii>,greater<pii> >q;
vector<pii>G[sz];
int dist[sz];
bool vis[sz];
#include<bits/stdc++.h>
using namespace std;
#define mx 505
long long matrix[mx][mx];
int main()
{
memset(matrix,INT_MAX,sizeof matrix);
#include<bits/stdc++.h>
using namespace std;
int inf=INT_MAX;
vector< pair<int,int> >edge;
int w[205][205];
int b[205];
int dist[205];
int n,m;