From 7bf103119ea00bb196157112c2e95b1c1c411774 Mon Sep 17 00:00:00 2001 From: llIllIllIllIllIllIllIllI <_@seol.pro> Date: Tue, 16 Dec 2025 23:46:08 +0900 Subject: [PATCH] =?UTF-8?q?[20251216]=20BOJ=20/=20G5=20/=20=EB=A9=80?= =?UTF-8?q?=ED=8B=B0=EB=B2=84=EC=8A=A4=20=E2=85=A1=20/=20=EC=84=A4?= =?UTF-8?q?=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\353\262\204\354\212\244 \342\205\241.md" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "Seol-JY/202512/16 BOJ G5 \353\251\200\355\213\260\353\262\204\354\212\244 \342\205\241.md" diff --git "a/Seol-JY/202512/16 BOJ G5 \353\251\200\355\213\260\353\262\204\354\212\244 \342\205\241.md" "b/Seol-JY/202512/16 BOJ G5 \353\251\200\355\213\260\353\262\204\354\212\244 \342\205\241.md" new file mode 100644 index 00000000..ed947f5f --- /dev/null +++ "b/Seol-JY/202512/16 BOJ G5 \353\251\200\355\213\260\353\262\204\354\212\244 \342\205\241.md" @@ -0,0 +1,46 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int M = Integer.parseInt(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + + List> spaces = new ArrayList<>(); + + for (int i = 0; i < M; i++) { + st = new StringTokenizer(br.readLine()); + List space = new ArrayList<>(); + Set set = new HashSet<>(); + + for (int j = 0; j < N; j++) { + int planet = Integer.parseInt(st.nextToken()); + set.add(planet); + space.add(planet); + } + + List sorted = new ArrayList<>(set); + Collections.sort(sorted); + + for (int j = 0; j < N; j++) { + int idx = Collections.binarySearch(sorted, space.get(j)); + space.set(j, idx); + } + spaces.add(space); + } + + int answer = 0; + for (int i = 0; i < M; i++) { + for (int j = i + 1; j < M; j++) { + if (spaces.get(i).equals(spaces.get(j))) answer++; + } + } + + System.out.println(answer); + } +} +```