From 6ae4899244b6cbeec0a8f24c669abb6a8572c3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=A9=EC=A0=95=ED=9B=88=20=28Hwang=20JungHun=29?= Date: Tue, 16 Nov 2021 16:40:58 +0900 Subject: [PATCH] =?UTF-8?q?[=ED=99=A9=EC=A0=95=ED=9B=88]=20=EC=B9=98?= =?UTF-8?q?=EC=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\231\251\354\240\225\355\233\210.java" | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 "solution/BOJ_2636_\354\271\230\354\246\210/\355\231\251\354\240\225\355\233\210.java" diff --git "a/solution/BOJ_2636_\354\271\230\354\246\210/\355\231\251\354\240\225\355\233\210.java" "b/solution/BOJ_2636_\354\271\230\354\246\210/\355\231\251\354\240\225\355\233\210.java" new file mode 100644 index 0000000..cfe0817 --- /dev/null +++ "b/solution/BOJ_2636_\354\271\230\354\246\210/\355\231\251\354\240\225\355\233\210.java" @@ -0,0 +1,80 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static int R, C, T = 0, pred = 0, remain = 0; + static int[] dr = {-1, 0, 1, 0}; + static int[] dc = {0, 1, 0, -1}; + static int[][] map; + static class Point{ + int r, c; + public Point(int r, int c){ + this.r = r; + this.c = c; + } + } + + public static void main(String[] args) throws Exception { + + st = new StringTokenizer(br.readLine()); + R = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + map = new int[R][C]; + for (int i = 0; i < R; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < C; j++) { + map[i][j] = Integer.parseInt(st.nextToken()); + } + } + + do { + remain = melt(); + pred = predict(); + T++; + }while(remain > pred); + + bw.write(T+"\n"+remain+"\n"); + bw.flush(); + bw.close(); + br.close(); + } + static int predict(){ + boolean[][] visit = new boolean[R][C]; + Queue Q = new ArrayDeque<>(); + Q.add(new Point(0, 0)); + visit[0][0] = true; + int tmp = 0; + + while(!Q.isEmpty()){ + Point cur = Q.poll(); + for (int i = 0; i < 4; i++) { + int nr = cur.r + dr[i]; + int nc = cur.c + dc[i]; + if(0<=nr && nr