From 7680a39df4d3428877c379d5ad2a1ef741009f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A3=BC=ED=98=81?= Date: Tue, 7 May 2024 09:05:43 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20PGMS=5F=EA=B0=80=EC=9E=A5=ED=81=B0?= =?UTF-8?q?=EC=88=98=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\264\354\243\274\355\230\201.java" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "4\354\243\274\354\260\250/\352\260\200\354\236\245\355\201\260\354\210\230/\352\260\200\354\236\245\355\201\260\354\210\230_\354\235\264\354\243\274\355\230\201.java" diff --git "a/4\354\243\274\354\260\250/\352\260\200\354\236\245\355\201\260\354\210\230/\352\260\200\354\236\245\355\201\260\354\210\230_\354\235\264\354\243\274\355\230\201.java" "b/4\354\243\274\354\260\250/\352\260\200\354\236\245\355\201\260\354\210\230/\352\260\200\354\236\245\355\201\260\354\210\230_\354\235\264\354\243\274\355\230\201.java" new file mode 100644 index 0000000..fb99641 --- /dev/null +++ "b/4\354\243\274\354\260\250/\352\260\200\354\236\245\355\201\260\354\210\230/\352\260\200\354\236\245\355\201\260\354\210\230_\354\235\264\354\243\274\355\230\201.java" @@ -0,0 +1,39 @@ +/* +어떤 것 먼저? + +*/ +import java.util.*; +class Solution { + public static class StringNum implements Comparable { + + String num; + + public StringNum(String num){ + this.num = num; + } + + @Override + public int compareTo(StringNum o1){ + return -1 * (this.num + o1.num).compareTo(o1.num + this.num); + } + + } + + public String solution(int[] numbers) { + String answer = ""; + + StringNum[] nums = new StringNum[numbers.length]; + + for(int i = 0; i < nums.length; i++) { + nums[i] = new StringNum(String.valueOf(numbers[i])); + } + + Arrays.sort(nums); + + if(nums[0].num.equals("0")) return "0"; + + for(int i=0; i Date: Tue, 7 May 2024 09:06:12 +0900 Subject: [PATCH 2/3] =?UTF-8?q?BOJ=5F16197=5F=EB=91=90=EB=8F=99=EC=A0=84?= =?UTF-8?q?=20=EC=95=8C=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\264\354\243\274\355\230\201.java" | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 "4\354\243\274\354\260\250/\353\221\220\353\217\231\354\240\204/\353\221\220\353\217\231\354\240\204_\354\235\264\354\243\274\355\230\201.java" diff --git "a/4\354\243\274\354\260\250/\353\221\220\353\217\231\354\240\204/\353\221\220\353\217\231\354\240\204_\354\235\264\354\243\274\355\230\201.java" "b/4\354\243\274\354\260\250/\353\221\220\353\217\231\354\240\204/\353\221\220\353\217\231\354\240\204_\354\235\264\354\243\274\355\230\201.java" new file mode 100644 index 0000000..90f1318 --- /dev/null +++ "b/4\354\243\274\354\260\250/\353\221\220\353\217\231\354\240\204/\353\221\220\353\217\231\354\240\204_\354\235\264\354\243\274\355\230\201.java" @@ -0,0 +1,130 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayDeque; +import java.util.Arrays; +import java.util.Queue; +import java.util.StringTokenizer; + +/** + * 시작 시간: 오후 9시 54분 + * + * 문제 해섞) + * - N*M 보드와 4개의 버튼 + * - 각각의 칸은 비어있거나, 벽 + * - 두 개의 빈칸에는 동전이 하나씩 놓여있다 + * - 버튼은 위, 오, 왼, 아 + * - 버튼을 누르면 두 동전이 동시에 이동한다 + * - 이동하려는 칸이 벽이면, 이동하지 않는다 + * - 칸이 없으면, 보드 바깥으로 떨어진다 + * - 그 외에는 한칸 이동한다. 이동하려는 칸에 동전이 있는 경우에도 한칸 이동한다. + * + * 두 동전 중 하나만 보드엣 ㅓ떨어뜨리기 위해 버튼을 쵯 ㅗ몇번 눌러야하는지 구행햐ㅏㄴ다. + * 첫째 줄에 두 동전 중 하나만 보드에서 떨어뜨리기 위해 눌러야 하는 버튼의 최소 횟수를 출력한다. + * 만약, 두 동전을 떨어뜨릴 수 없거나, 버튼을 10번보다 많이 눌러야 한다면, -1을 출력한다. + * + * + * @author GODJUHYEOK + * + */ +public class Main { + + private static class Coin { + + int r; + int c; + + public Coin(int r, int c) { + this.r = r; + this.c = c; + } + + } + + private static int N, M; + private static int[][] deltas = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}}; + private static boolean[][][][] visited; + private static char[][] map; + + 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()); + + map = new char[N][M]; + visited = new boolean[N][M][N][M]; + + Coin[] arr = {null, null}; + + + for(int i=0, idx=0; i q = new ArrayDeque(); + visited[arr[0].r][arr[0].c][arr[1].r][arr[1].c] = true; + q.offer(arr); + + int turn = 0; + while(turn < 10 && !q.isEmpty()) { + + int qSize = q.size(); + turn++; + for (int k=0; k=N || c>=M; + } + +} From 4e7942415cab29788bb6f83d4f511d8db4d86574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A3=BC=ED=98=81?= Date: Tue, 7 May 2024 09:06:27 +0900 Subject: [PATCH 3/3] =?UTF-8?q?BOJ=5F2176=5F=ED=95=A9=EB=A6=AC=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=EC=9D=B4=EB=8F=99=EA=B2=BD=EB=A1=9C=20=EC=95=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=EC=A6=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\264\354\243\274\355\230\201.java" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "4\354\243\274\354\260\250/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234_\354\235\264\354\243\274\355\230\201.java" diff --git "a/4\354\243\274\354\260\250/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234_\354\235\264\354\243\274\355\230\201.java" "b/4\354\243\274\354\260\250/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234_\354\235\264\354\243\274\355\230\201.java" new file mode 100644 index 0000000..80a51de --- /dev/null +++ "b/4\354\243\274\354\260\250/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234/\355\225\251\353\246\254\354\240\201\354\235\270\354\235\264\353\217\231\352\262\275\353\241\234_\354\235\264\354\243\274\355\230\201.java" @@ -0,0 +1,68 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class Main { + static final int MAX = 1001; + static final int INF = Integer.MAX_VALUE; + static ArrayList[] adj = new ArrayList[MAX]; + static int[] dist = new int[MAX]; + static int[] dp = new int[MAX]; + + static class Pair implements Comparable { + int cost, vertex; + public Pair(int cost, int vertex) { + this.cost = cost; + this.vertex = vertex; + } + public int compareTo(Pair other) { + return Integer.compare(this.cost, other.cost); + } + } + + public static void dijkstra(int start) { + Arrays.fill(dist, INF); + PriorityQueue pq = new PriorityQueue<>(); + dist[start] = 0; + pq.add(new Pair(0, start)); + while (!pq.isEmpty()) { + Pair top = pq.poll(); + int curCost = top.cost; + int cur = top.vertex; + if (dist[cur] != curCost) continue; + for (Pair edge : adj[cur]) { + int nextCost = edge.cost; + int next = edge.vertex; + if (dist[next] > curCost + nextCost) { + dist[next] = curCost + nextCost; + pq.add(new Pair(dist[next], next)); + } + if (dist[cur] > dist[next]) { + dp[cur] += dp[next]; + } + } + } + } + + 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()); + for (int i = 0; i < MAX; i++) { + adj[i] = new ArrayList<>(); + } + dp[2] = 1; + while (m-- > 0) { + st = new StringTokenizer(br.readLine()); + int a = Integer.parseInt(st.nextToken()); + int b = Integer.parseInt(st.nextToken()); + int c = Integer.parseInt(st.nextToken()); + adj[a].add(new Pair(c, b)); + adj[b].add(new Pair(c, a)); + } + dijkstra(2); + System.out.println(dp[1]); + } +}