-
Notifications
You must be signed in to change notification settings - Fork 0
/
no9372.java
57 lines (38 loc) · 1.42 KB
/
no9372.java
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
55
56
57
package Algoritm.day7;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
// 상근이의 여행
public class no9372 {
private static int n, m;
private static int cnt;
private static ArrayList<Integer>[] list;
private static boolean[] visit;
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(reader.readLine());
StringBuilder sb = new StringBuilder();
StringTokenizer st;
while (t-- > 0) {
st = new StringTokenizer(reader.readLine());
n = Integer.parseInt(st.nextToken()); //국가수
m = Integer.parseInt(st.nextToken()); //비행기종류
list = new ArrayList[n + 1];
visit = new boolean[n + 1];
for (int i = 0; i <= n; i++) {
list[i] = new ArrayList<>();
}
for (int i = 0; i < m; i++) {
st = new StringTokenizer(reader.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
list[a].add(b);
list[b].add(a);
}
sb.append(n - 1 + "\n");
}
System.out.print(sb);
}
}