From 30e9b33317a0737d7699e0ab26182061d425f15b Mon Sep 17 00:00:00 2001 From: oncsr Date: Tue, 11 Mar 2025 11:41:55 +0900 Subject: [PATCH] =?UTF-8?q?[20250311]=20BOJ=20/=20P5=20/=20=EB=B0=B0?= =?UTF-8?q?=EC=97=B4=EC=97=90=EC=84=9C=20=EC=9D=B4=EB=8F=99=20/=20?= =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\204\234 \354\235\264\353\217\231.md" | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 "khj20006/202503/11 BOJ P5 \353\260\260\354\227\264\354\227\220\354\204\234 \354\235\264\353\217\231.md" diff --git "a/khj20006/202503/11 BOJ P5 \353\260\260\354\227\264\354\227\220\354\204\234 \354\235\264\353\217\231.md" "b/khj20006/202503/11 BOJ P5 \353\260\260\354\227\264\354\227\220\354\204\234 \354\235\264\353\217\231.md" new file mode 100644 index 00000000..79f960d7 --- /dev/null +++ "b/khj20006/202503/11 BOJ P5 \353\260\260\354\227\264\354\227\220\354\204\234 \354\235\264\353\217\231.md" @@ -0,0 +1,109 @@ +```java + +import java.util.*; +import java.io.*; + + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N; + static int[][] A; + + static int[] dx = {1,0,-1,0}; + static int[] dy = {0,1,0,-1}; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = Integer.parseInt(br.readLine()); + A = new int[N][N]; + for(int i=0;i= 0) { + ans = Math.min(ans, findMin()); + reduce(); + } + bw.write(ans + "\n"); + + } + + static void reduce() { + for(int i=0;i>1; + // m이하인 칸들로만 도달할 수 있는지? + while(s>1; + } + return m; + + } + + // limit 제한 내에서의 bfs + static boolean bfs(int limit) { + + if(A[0][0] > limit) return false; + + Queue Q = new LinkedList<>(); + boolean[][] vis = new boolean[N][N]; + Q.offer(new int[] {0,0}); + vis[0][0] = true; + while(!Q.isEmpty()) { + + int[] now = Q.poll(); + int x = now[0], y = now[1]; + if(x == N-1 && y == N-1) return true; + for(int i=0;i<4;i++) { + int xx = x+dx[i], yy = y+dy[i]; + if(safe(xx,yy) && A[xx][yy] <= limit && A[xx][yy] >= 0 && !vis[xx][yy]) { + vis[xx][yy] = true; + Q.offer(new int[] {xx,yy}); + } + } + + } + + return false; + + } + + static boolean safe(int x, int y) { + return 0<=x&&x