From b8d1dee58bc1519746278d755dfda45c566fce84 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:45:24 +0900 Subject: [PATCH] =?UTF-8?q?Create=2017=20BOJ=20G3=20=EB=B4=84=EB=B2=84?= =?UTF-8?q?=EB=A7=A8=202.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\264\204\353\262\204\353\247\250 2.md" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "suyeun84/202502/17 BOJ G3 \353\264\204\353\262\204\353\247\250 2.md" diff --git "a/suyeun84/202502/17 BOJ G3 \353\264\204\353\262\204\353\247\250 2.md" "b/suyeun84/202502/17 BOJ G3 \353\264\204\353\262\204\353\247\250 2.md" new file mode 100644 index 00000000..9c052ec5 --- /dev/null +++ "b/suyeun84/202502/17 BOJ G3 \353\264\204\353\262\204\353\247\250 2.md" @@ -0,0 +1,63 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + StringBuilder sb = new StringBuilder(); + + int R = Integer.parseInt(st.nextToken()); + int C = Integer.parseInt(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + int[][] board = new int[R][C]; + int[][] dir = new int[][] {{1,0},{-1,0},{0,1},{0,-1}}; + + for (int i = 0; i < R; i++) { + String line = br.readLine(); + for (int j = 0; j < C; j++) { + if (line.charAt(j) == '.') continue; + board[i][j] = 2; + } + } + int time = 1; + if(N > 5) N = (N % 4) + 4; + while (time < N) { + if (time % 2 == 1) { //폭탄 설치 + for (int i = 0; i < R; i++) { + for (int j = 0; j < C; j++) { + if (board[i][j] == 0) board[i][j] = 3; + else board[i][j]--; + } + } + } else { //폭탄시간 감소 + for (int i = 0; i < R; i++) { + for (int j = 0; j < C; j++) { + if (board[i][j] == 1) { + board[i][j]--; + for (int[] d : dir) { + int ny = i + d[0]; + int nx = j + d[1]; + if (ny < 0 || ny >= R || nx < 0 || nx >= C) continue; + if(board[ny][nx] == 1) continue; + board[ny][nx] = 0; + } + } else if (board[i][j] > 1) board[i][j]--; + } + } + } + time++; + } + for (int i = 0; i < R; i++) { + for (int j = 0; j < C; j++) { + if (board[i][j] > 0) sb.append('O'); + else sb.append('.'); + } + sb.append("\n"); + } + System.out.println(sb); + } +} + +```