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 1/2] =?UTF-8?q?[20250909]=20BAJ=20/=20=EA=B3=A8=EB=93=9C5?= =?UTF-8?q?=20/=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; + } + +} + + +``` From 486d91f06e7f6a43f0d7e7086494379e0257fcb9 Mon Sep 17 00:00:00 2001 From: MinjoongKim <76093968+kmj-99@users.noreply.github.com> Date: Tue, 16 Sep 2025 22:13:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[20250916]/BJ/=EA=B3=A8=EB=93=9C1/=ED=9A=A1?= =?UTF-8?q?=EB=8B=A8=EB=B3=B4=EB=8F=84/=EA=B9=80=EB=AF=BC=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\353\213\250\353\263\264\353\217\204.md" | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 "kmj-99/202509/16 \355\232\241\353\213\250\353\263\264\353\217\204.md" diff --git "a/kmj-99/202509/16 \355\232\241\353\213\250\353\263\264\353\217\204.md" "b/kmj-99/202509/16 \355\232\241\353\213\250\353\263\264\353\217\204.md" new file mode 100644 index 0000000..d933562 --- /dev/null +++ "b/kmj-99/202509/16 \355\232\241\353\213\250\353\263\264\353\217\204.md" @@ -0,0 +1,78 @@ +```java + + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.*; + +public class Main { + private static int N, M; + private static List> crossWalk; + private static long[] distance; + static class Node implements Comparable{ + int index; + long cost; + Node(int index, long cost) { + this.index = index; + this.cost = cost; + } + + @Override + public int compareTo(Node o) { + return Long.compare(this.cost, o.cost); + } + } + private static void dijkstra() { + PriorityQueue queue = new PriorityQueue<>(); + queue.offer(new Node(1, 0)); + distance[1] = 0; + + while(!queue.isEmpty()) { + Node currentNode = queue.poll(); + if (currentNode.cost > distance[currentNode.index]) + continue; + for (Node next :crossWalk.get(currentNode.index)) { + int nextIndex = next.index; + long nextCost; + if (currentNode.cost <= next.cost) { + nextCost = next.cost + 1; + } else { + // 모듈러 연산 + nextCost = ((long) Math.ceil(((double)currentNode.cost-next.cost)/M)) * M + next.cost + 1; + } + if (nextCost < distance[nextIndex]) { + distance[nextIndex] = nextCost; + queue.offer(new Node(nextIndex, nextCost)); + } + } + } + } + public static void main(String[] args) throws Exception { + StringTokenizer st; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + distance = new long[N+1]; + Arrays.fill(distance, Long.MAX_VALUE); + + crossWalk = new ArrayList<>(); + for (int i = 0; i <= N; i++) { + crossWalk.add(new ArrayList()); + } + for (int i = 0; i < M; i++) { + st = new StringTokenizer(br.readLine()); + int u = Integer.parseInt(st.nextToken()); + int v = Integer.parseInt(st.nextToken()); + crossWalk.get(u).add(new Node(v, i)); + crossWalk.get(v).add(new Node(u, i)); + } + dijkstra(); + System.out.println(distance[N]); + } +} + + +```