Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 코딩테스트
- 프로그래머스
- 운동기록
- BFS
- 문제해결
- math
- 이분탐색
- 러닝일지
- db
- 백준
- dfs
- 건강
- 문제풀이
- MySQL
- 시뮬레이션
- Java
- 투포인터
- 알고리즘
- 문자열
- COS PRO
- SQL
- binary search
- 자바
- 코테
- priorityqueue
- BOJ
- SWEA
- DP
- greedy
- oracle
Archives
- Today
- Total
슈콩
[BOJ] 백준 18869 멀티버스 Ⅱ 본문
[문제]
https://www.acmicpc.net/problem/18869
[소스 코드]
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());
int[][] planets = new int[m][n];
List<Integer>[] sortedPlanets = new ArrayList[m];
int[][] order = new int[m][n];
for(int i=0;i<m;i++) {
st = new StringTokenizer(br.readLine());
HashSet<Integer> hs = new HashSet<>();
for(int j=0;j<n;j++) {
planets[i][j] = Integer.parseInt(st.nextToken());
hs.add(planets[i][j]);
}
sortedPlanets[i] = new ArrayList<>(hs);
Collections.sort(sortedPlanets[i]);
for(int j=0;j<n;j++) {
order[i][j] = Collections.binarySearch(sortedPlanets[i],planets[i][j]);
}
}
int result = 0;
for(int i=0;i<m;i++) {
for(int j=i+1;j<m;j++) {
if(Arrays.equals(order[i],order[j])) {
result++;
}
}
}
System.out.println(result);
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 2143 두 배열의 합 (2) | 2025.09.21 |
|---|---|
| [BOJ] 백준 2110 공유기 설치 (0) | 2025.09.20 |
| [BOJ] 백주 1822 차집합 (0) | 2025.09.19 |
| [BOJ] 백준 14502 연구소 (2) | 2025.09.19 |
| [BOJ] 백준 14499 주사위 굴리기 (0) | 2025.09.19 |