File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 22import java.awt.* ;
33import java.io.* ;
44import java.util.* ;
5- import java.util.List ;
65import java.util.Queue ;
76
87public 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 );
You can’t perform that action at this time.
0 commit comments