Skip to content

Commit 30ba354

Browse files
authored
Merge pull request #1691 from AlgorithmWithGod/Seol-JY
[20251216] BOJ / G5 / 멀티버스 Ⅱ / 설진영
2 parents cbee362 + 7bf1031 commit 30ba354

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
StringTokenizer st = new StringTokenizer(br.readLine());
9+
10+
int M = Integer.parseInt(st.nextToken());
11+
int N = Integer.parseInt(st.nextToken());
12+
13+
List<List<Integer>> spaces = new ArrayList<>();
14+
15+
for (int i = 0; i < M; i++) {
16+
st = new StringTokenizer(br.readLine());
17+
List<Integer> space = new ArrayList<>();
18+
Set<Integer> set = new HashSet<>();
19+
20+
for (int j = 0; j < N; j++) {
21+
int planet = Integer.parseInt(st.nextToken());
22+
set.add(planet);
23+
space.add(planet);
24+
}
25+
26+
List<Integer> sorted = new ArrayList<>(set);
27+
Collections.sort(sorted);
28+
29+
for (int j = 0; j < N; j++) {
30+
int idx = Collections.binarySearch(sorted, space.get(j));
31+
space.set(j, idx);
32+
}
33+
spaces.add(space);
34+
}
35+
36+
int answer = 0;
37+
for (int i = 0; i < M; i++) {
38+
for (int j = i + 1; j < M; j++) {
39+
if (spaces.get(i).equals(spaces.get(j))) answer++;
40+
}
41+
}
42+
43+
System.out.println(answer);
44+
}
45+
}
46+
```

0 commit comments

Comments
 (0)