From 3b560158ba6440f2a3341e154f76ed56d60ce187 Mon Sep 17 00:00:00 2001 From: MinjoongKim <76093968+kmj-99@users.noreply.github.com> Date: Tue, 9 Sep 2025 09:06:52 +0900 Subject: [PATCH] =?UTF-8?q?[20250909]=20BAJ=20/=20=EA=B3=A8=EB=93=9C5=20/?= =?UTF-8?q?=20=EA=B0=90=EC=8B=9C=ED=94=BC=ED=95=98=EA=B8=B0=20/=20?= =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kmj-99/202509/18428.md | 127 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 kmj-99/202509/18428.md diff --git a/kmj-99/202509/18428.md b/kmj-99/202509/18428.md new file mode 100644 index 0000000..2d97c60 --- /dev/null +++ b/kmj-99/202509/18428.md @@ -0,0 +1,127 @@ +```java + +import java.io.*; +import java.util.*; + + +public class Main { + static class Node{ + int x; + int y; + + public Node(int x, int y) { + this.x = x; + this.y = y; + } + } + + static final int[] dx = {0, 0, 1, -1}; + static final int[] dy = {1, -1, 0, 0}; + static ArrayList student = new ArrayList<>(); + static int N; + static String[][] map; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + map = new String[N][N]; + + for(int i=0; i q = new LinkedList<>(); + String[][] copyMap = new String[N][N]; + boolean[][] check = new boolean[N][N]; + + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + copyMap[i][j] = map[i][j]; + } + } + + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (copyMap[i][j].equals("T")) { + q.add(new Node(i, j)); + check[i][j] = true; + } + } + } + + while (!q.isEmpty()) { + Node now = q.poll(); + int x = now.x; + int y = now.y; + + for (int k = 0; k < 4; k++) { + int nx = x + dx[k]; + int ny = y + dy[k]; + + while(0 <= nx && nx < N && 0 <= ny && ny < N) { + if (!copyMap[nx][ny].equals("O")) { + check[nx][ny] = true; + nx += dx[k]; + ny += dy[k]; + }else{ + break; + } + } + } + } + if(catchStudent(check)){ + System.out.println("YES"); + System.exit(0); + } + } + + private static boolean catchStudent(boolean[][] check) { + + for (Node node : student) { + if (check[node.x][node.y] == true) { + return false; + } + } + return true; + } + +} + + +```