From 98c1fc4d7b6094a1ef8780d48b61ccccebd05641 Mon Sep 17 00:00:00 2001 From: yeong Date: Tue, 4 Feb 2025 01:00:32 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[CT]=202?= =?UTF-8?q?=EA=B0=9C=EC=9D=98=20=EC=82=AC=ED=83=95=5F250203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354235円230円_354円202円254円355円203円225円.java" | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 "CodeTree/2015-2016353円205円204円/JY_2352円260円234円354円235円230円_354円202円254円355円203円225円.java" diff --git "a/CodeTree/2015-2016353円205円204円/JY_2352円260円234円354円235円230円_354円202円254円355円203円225円.java" "b/CodeTree/2015-2016353円205円204円/JY_2352円260円234円354円235円230円_354円202円254円355円203円225円.java" new file mode 100644 index 00000000..24465a80 --- /dev/null +++ "b/CodeTree/2015-2016353円205円204円/JY_2352円260円234円354円235円230円_354円202円254円355円203円225円.java" @@ -0,0 +1,143 @@ +import java.io.*; +import java.util.*; +public class JY_2개의_사탕 { + + static int N, M; + static char[][] g; + // 상 하 좌 우 + static int[] dx = {-1, 1, 0, 0}; + static int[] dy = {0, 0, -1, 1}; + static class Candy { + int x, y; + + public Candy(int x, int y) { + super(); + this.x = x; + this.y = y; + } + + @Override + public String toString() { + return "Candy [x=" + x + ", y=" + y + "]"; + } + + } + static int ans; + + public static void main(String[] args) throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + g = new char[N][M]; + Candy red = new Candy(-1, -1); + Candy blue = new Candy(-1, -1); + + for(int i=0; i 10) System.out.println(-1); + else System.out.println(ans); + + + } + public static void printG() { + for(int i=0; i 10) return; + // 이미 구해진 값보다 많다면 중단 + if(cnt> ans) return; + + for(int i=0; i<4; i++) { + Candy nr = move(r, i); + Candy nb = move(b, i); + + // 둘 위치가 같음 -> 위치 재조정 + if(nr.x == nb.x && nr.y == nb.y) { + // 같은 위치가 도착점이면 X + if(g[nr.x][nr.y] == 'O') continue; + // 상 + if(i == 0) { + if(r.x < b.x) { + nb.x += 1; + } else { + nr.x += 1; + } + } + // 하 + else if(i == 1) { + if(r.x> b.x) { + nb.x -= 1; + } else { + nr.x -= 1; + } + } + // 좌 + else if(i == 2) { + if(r.y < b.y) { + nb.y += 1; + } else { + nr.y += 1; + } + } + // 우 + else { + if(r.y> b.y) { + nb.y -= 1; + } else { + nr.y -= 1; + } + } + } + if(r.x == nr.x && r.y == nr.y && b.x == nb.x && b.y == nb.y) continue; + exit(nr, nb, cnt+1); + + + } + } + public static Candy move(Candy c, int dir) { + Candy nc = new Candy(c.x, c.y); + while(true) { + // 현제 위치가 도착점이면 중단 + if(g[nc.x][nc.y] == 'O') break; + int nx = nc.x + dx[dir]; + int ny = nc.y + dy[dir]; + + // 다음이 벽이면 중단 + if(g[nx][ny] == '#') break; + nc.x = nx; + nc.y = ny; + } + return nc; + } + +} From 83fc999cb0fdd2e79722340993ab1fbe23379b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81?= Date: Wed, 5 Feb 2025 13:13:30 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81:=20[BOJ]=201939?= =?UTF-8?q?=20=EC=A4=91=EB=9F=89=EC=A0=9C=ED=95=9C=5F250205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/JY_1939.java" | 84 ++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/JY_1939.java" diff --git "a/BOJ/1000-5000353円262円210円/JY_1939.java" "b/BOJ/1000-5000353円262円210円/JY_1939.java" new file mode 100644 index 00000000..c84ac60a --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/JY_1939.java" @@ -0,0 +1,84 @@ +import java.io.*; +import java.util.*; + +public class JY_1939 { + + static int N, M; + static List[] g; + static boolean[] visited; + static int ea, eb; + static boolean isOk; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + g = new ArrayList[N+1]; + for(int i=1; i(); + } + + int mc = 0; + for(int i=0; ieb로 갈 수 있는지 탐색 + canGo(ea, mid); + if(isOk) { + ans = mid; + s = mid + 1; + } else { + e = mid - 1; + } + + } + + System.out.println(ans); + } + public static void canGo(int now, int cost) { + if(now == eb) { + isOk = true; + return; + } + + visited[now] = true; + + for(int[] next : g[now]) { + if(visited[next[0]]) continue; + if(next[1] < cost) continue; + + canGo(next[0], cost); + } + + } + +} From 9ba4f090343b189ec5b2d3f57f13021ce23268ca Mon Sep 17 00:00:00 2001 From: yeong Date: Wed, 5 Feb 2025 20:59:02 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=98=81=20:=20[BOJ]=202?= =?UTF-8?q?169=20=EB=A1=9C=EB=B4=87=20=EC=A1=B0=EC=A2=85=ED=95=98=EA=B8=B0?= =?UTF-8?q?=5F250205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/JY_2169.java" | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/JY_2169.java" diff --git "a/BOJ/1000-5000353円262円210円/JY_2169.java" "b/BOJ/1000-5000353円262円210円/JY_2169.java" new file mode 100644 index 00000000..799d2899 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/JY_2169.java" @@ -0,0 +1,59 @@ +import java.io.*; +import java.util.*; +public class JY_2169 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + int[][] g = new int[N+1][M+1]; + int[][] dp = new int[N+1][M+1]; + for(int i=1; i오 + int[] t1 = new int[M+1]; + // t2: 오-> 왼 + int[] t2 = new int[M+1]; + + t1[1] = dp[i-1][1] + g[i][1]; + for(int j=2; j=0; j--) { + t2[j] = Math.max(dp[i-1][j], t2[j+1]) + g[i][j]; + } + + // dp에 반영 + for(int j=1; j

AltStyle によって変換されたページ (->オリジナル) /