-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAugLong3.cpp
More file actions
54 lines (51 loc) · 1.19 KB
/
AugLong3.cpp
File metadata and controls
54 lines (51 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
vector <int> v[100001];
// int level[1000]; // to determine the level of each node
bool vis[100001]; //mark the node if visited
void bfs(int s) {
queue <int> q;
q.push(s);
level[ s ] = 0 ; //setting the level of sources node as 0.
vis[ s ] = true;
std::vector<int> path;
while(!q.empty())
{
int p = q.front();
q.pop();
if(p == v){
break;
}
for(int i = 0;i < v[ p ].size() ; i++)
{
if(vis[ v[ p ][ i ] ] == false)
{
//setting the level of each node with an increment in the level of parent node
level[ v[ p ][ i ] ] = level[ p ]+1;
q.push(v[ p ][ i ]);
vis[ v[ p ][ i ] ] = true;
}
}
}
}
void initialize() {
for(int i = 0;i < 100001;++i)
{vis[i] = false;
v[i].clear();
}
}
int main(){
int n, m;
cin>>n>>m;
int a[n+1];
for(int i = 1;i<=n;i++){
cin>>a[i];
}
for(int i = 1;i<n;i++){
int x,y; cin>>x>>y;
v[x].push_back(y);
}
int query; cin>> query;
if(query == 1){
}
}