-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilding.java
More file actions
38 lines (24 loc) · 756 Bytes
/
Building.java
File metadata and controls
38 lines (24 loc) · 756 Bytes
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
public class Building{
ArrayList<ArrayList<Integer> adj;
public Building(int n){
adj = new ArrayList<>();
for(int i = 0; i < n; i++){
adj.add(new ArrayList<>());
}
}
public void addedge(int source , int destination){
adj.get(source - 1).add(destination);
adj.get(destination - 1).add(source);
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Building b = new Building(n);
int m = sc.nextInt();
for(int i =0; i < m; i++){
int source = sc.nextInt();
int destination = sc.nextInt();
addedge(source,destination);
}
}
}