-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbaekjoon_9375.java
44 lines (36 loc) · 1.08 KB
/
baekjoon_9375.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
package com.ssafy.algo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
public class baekjoon_9375 {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int T = Integer.parseInt(br.readLine());
for (int tc = 1; tc <= T; ++tc) {
int N = Integer.parseInt(br.readLine());
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < N; ++i) {
String cur = br.readLine();
String curs[] = cur.split(" ");
if (map.containsKey(curs[1])) {
map.put(curs[1], map.get(curs[1]) + 1);
} else {
map.put(curs[1], 1);
}
}
int sum = 1;
for (int y : map.values()) {
sum *= y + 1;
}
bw.write(sum - 1 + "\n");
}
bw.flush();
br.close();
bw.close();
}
}