Graph Template
Wed Jul 14 2021 04:37:27 GMT+0000 (Coordinated Universal Time)
Saved by
@Randumkeng
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define maxn 1000001
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mem(a, val) memset(a, val, sizeof(a))
//===========================================================================================================================================================
ll vis[maxn],in[maxn],out[maxn],dis[maxn];
vector<ll> adj[maxn] ;
queue<ll> q ;
int main()
{
fio;
ll t=1;
cin >> t;
while (t--)
{
ll n,k;
cin>>n>>k;
for (ll i = 0; i <= n + 2; i++)
{
adj[i].clear();
vis[i] = dis[i] = in[i] = out[i] = 0;
}
while(k--)
{
ll x,y;
cin>>x>>y;
adj[x].pb(y);
adj[y].pb(x);
}
// traverse algo
}
return 0;
}
content_copyCOPY
CP - graph template - copy this while solving graph problems
Comments