Skip to content

Commit 689cd3a

Browse files
committed
[20251215] BOJ / G2 / 벽 부수고 이동하기 4 / 김민진
1 parent 6d147d1 commit 689cd3a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

zinnnn37/202512/15 BOJ G2 벽 부수고 이동하기 4.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import java.awt.*;
33
import java.io.*;
44
import java.util.*;
5-
import java.util.List;
65
import java.util.Queue;
76

87
public class BJ_16946_벽_부수고_이동하기_4 {
@@ -19,7 +18,7 @@ public class BJ_16946_벽_부수고_이동하기_4 {
1918
private static int[][] matrix;
2019
private static boolean[][] visited;
2120
private static Queue<Point> q;
22-
private static List<Integer> list;
21+
private static Set<Integer> set;
2322
private static Map<Integer, Integer> groups;
2423

2524
public static void main(String[] args) throws IOException {
@@ -42,7 +41,7 @@ public class BJ_16946_벽_부수고_이동하기_4 {
4241
}
4342
visited = new boolean[N][M];
4443
q = new ArrayDeque<>();
45-
list = new ArrayList<>();
44+
set = new HashSet<>();
4645
groups = new HashMap<>();
4746
}
4847

@@ -97,14 +96,14 @@ public class BJ_16946_벽_부수고_이동하기_4 {
9796
sb.append(0);
9897
} else {
9998
cnt = 1;
100-
list.clear();
99+
set.clear();
101100
for (int d = 0; d < 4; d++) {
102101
int nx = i + dx[d];
103102
int ny = j + dy[d];
104103

105-
if (OOB(nx, ny) || matrix[nx][ny] == 1 || list.contains(matrix[nx][ny])) continue;
104+
if (OOB(nx, ny) || matrix[nx][ny] == 1 || set.contains(matrix[nx][ny])) continue;
106105

107-
list.add(matrix[nx][ny]);
106+
set.add(matrix[nx][ny]);
108107
cnt += groups.get(matrix[nx][ny]);
109108
}
110109
sb.append(cnt % 10);

0 commit comments

Comments
 (0)