From f163ff36fa197b97d7e537ddb0ac3055b56f8ab6 Mon Sep 17 00:00:00 2001 From: Yoo Byeong gue <106210750+Gyulguma@users.noreply.github.com> Date: Mon, 19 May 2025 10:07:05 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[Baekjoon-15898]=20=ED=94=BC=EC=95=84?= =?UTF-8?q?=EC=9D=98=20=EC=95=84=ED=8B=80=EB=A6=AC=EC=97=90=20-=EC=8B=A0?= =?UTF-8?q?=EB=B9=84=ED=95=9C=20=EB=8C=80=ED=9A=8C=EC=9D=98=20=EC=97=B0?= =?UTF-8?q?=EA=B8=88=EC=88=A0=EC=82=AC-?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...352\270\210\354\210\240\354\202\254-.java" | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 "\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-15898] \355\224\274\354\225\204\354\235\230 \354\225\204\355\213\200\353\246\254\354\227\220 -\354\213\240\353\271\204\355\225\234 \353\214\200\355\232\214\354\235\230 \354\227\260\352\270\210\354\210\240\354\202\254-.java" diff --git "a/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-15898] \355\224\274\354\225\204\354\235\230 \354\225\204\355\213\200\353\246\254\354\227\220 -\354\213\240\353\271\204\355\225\234 \353\214\200\355\232\214\354\235\230 \354\227\260\352\270\210\354\210\240\354\202\254-.java" "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-15898] \355\224\274\354\225\204\354\235\230 \354\225\204\355\213\200\353\246\254\354\227\220 -\354\213\240\353\271\204\355\225\234 \353\214\200\355\232\214\354\235\230 \354\227\260\352\270\210\354\210\240\354\202\254-.java" new file mode 100644 index 00000000..a1fbd159 --- /dev/null +++ "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-15898] \355\224\274\354\225\204\354\235\230 \354\225\204\355\213\200\353\246\254\354\227\220 -\354\213\240\353\271\204\355\225\234 \353\214\200\355\232\214\354\235\230 \354\227\260\352\270\210\354\210\240\354\202\254-.java" @@ -0,0 +1,176 @@ +import java.io.*; +import java.util.*; + +public class Main { + private static final int ORDER_SIZE = 3; + private static final int MATTER_SIZE = 4; + private static final int KILN_SIZE = 5; + + private static int n; + private static Matter[][] matters; + private static int[][] order; + private static int result; + private static Matter kiln; + private static int[][] position = {{0,0},{0,1},{1,0},{1,1}}; + private static boolean[] visited; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + n = Integer.parseInt(br.readLine()); + matters = new Matter[n][4]; + for(int i=0; i 9) value = 9; + kiln.value[ni][nj] = value; + + //원소 변경 + if(matter.element[i][j] == 'W') continue; + kiln.element[ni][nj] = matter.element[i][j]; + } + } + } + + private static int calcul() { + int r=0, b=0, g=0, y=0; + + for(int i=0; i Date: Mon, 19 May 2025 10:07:25 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[Baekjoon-17837]=20=EC=83=88=EB=A1=9C?= =?UTF-8?q?=EC=9A=B4=20=EA=B2=8C=EC=9E=84=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\232\264 \352\262\214\354\236\204 2.java" | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 "\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-17837] \354\203\210\353\241\234\354\232\264 \352\262\214\354\236\204 2.java" diff --git "a/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-17837] \354\203\210\353\241\234\354\232\264 \352\262\214\354\236\204 2.java" "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-17837] \354\203\210\353\241\234\354\232\264 \352\262\214\354\236\204 2.java" new file mode 100644 index 00000000..dff27277 --- /dev/null +++ "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-17837] \354\203\210\353\241\234\354\232\264 \352\262\214\354\236\204 2.java" @@ -0,0 +1,195 @@ +import java.io.*; +import java.util.*; + +public class Main { + private static int[][] d = {{0,1},{0,-1},{-1,0},{1,0}}; + + 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 k = Integer.parseInt(st.nextToken()); + + Cell[][] board = new Cell[n][n]; + for(int i=0; i=n || ny<0 || ny>=n || board[nx][ny].type == 2) { + //방향전환하고 + piece.changeDir(); + //이동할 곳 + nx = piece.x + d[piece.dir][0]; + ny = piece.y + d[piece.dir][1]; + + //이동할 곳이 다시 보드 밖이거나 파란색일 경우 이동하지 않음 + if(nx<0 || nx>=n || ny<0 || ny>=n || board[nx][ny].type == 2) continue; + } + //흰색이거나 빨간색인 경우 이동함 + //말 아래에 말이 있던 경우에는 연결 끊기 + if(piece.down != null) { + piece.down.up = null; + piece.down = null; + } + + //움직이는 말이 보드에 직접 맞닿아 있는 말이라면 기존 칸 위에는 말이 없음 + if(board[piece.x][piece.y].bottom == piece) + board[piece.x][piece.y].bottom = null; + + //말 이동 + piece.x = nx; + piece.y = ny; + piece.update(); + + //빨간색이고 말 위에 말이 있다면 + if(board[nx][ny].type == 1 && piece.up != null) { + //뒤집음 + Piece bottom = piece; + while(piece != null) { + Piece temp = piece.up; + piece.up = piece.down; + piece.down = temp; + bottom = piece; + piece = temp; + } + + piece = bottom; + } + + //해당 칸에 말이 없을 경우 + if(board[nx][ny].bottom == null) { + board[nx][ny].bottom = piece; + } + + //해당 칸에 말이 있을 경우 + else { + Piece top = board[nx][ny].bottom.getTop(); + piece.down = top; + top.up = piece; + } + + //개수 체크 + if(board[nx][ny].bottom.size() >= 4) { + System.out.println(count); + return; + } + } + } + + System.out.println(-1); + } + + private static class Cell{ + int type; + Piece bottom; + + public Cell(int type) { + this.type = type; + } + + @Override + public String toString() { + String sType = "W"; + if(type == 1) sType = "R"; + else if(type == 2) sType = "B"; + + String sbottom = bottom == null ? "x" : bottom.toString(); + + return "["+sType+"/"+sbottom+"]"; + } + } + + private static class Piece{ + int num; + int x, y; + int dir; + Piece up, down; + + public Piece(int num, int x, int y, int dir) { + this.num = num; + this.x = x; + this.y = y; + this.dir = dir; + } + + public int size() { + Piece next = this; + int count = 1; + while(next.up != null) { + next = next.up; + count++; + } + return count; + } + + public Main.Piece getTop() { + Piece next = this; + while(next.up != null) { + next = next.up; + } + return next; + } + + public void update() { + Piece next = this.up; + while(next != null) { + next.x = this.x; + next.y = this.y; + next = next.up; + } + } + + public void changeDir() { + switch(dir) { + case 0: dir = 1; break; + case 1: dir = 0; break; + case 2: dir = 3; break; + case 3: dir = 2; break; + } + } + + public String getSDir() { + String sdir = "→"; + if(dir == 1) sdir = "←"; + else if(dir == 2) sdir = "↑"; + else if(dir == 3) sdir = "↓"; + return sdir; + } + + @Override + public String toString() { + String snum = num+"("+getSDir()+")"; + Piece next = this.up; + while(next != null) { + snum += ","+next.num+"("+next.getSDir()+")"; + next = next.up; + } + return snum; + } + } +} From 8d6409287b8a381fd1a6d5187cce39c736a3c9a0 Mon Sep 17 00:00:00 2001 From: Yoo Byeong gue <106210750+Gyulguma@users.noreply.github.com> Date: Mon, 19 May 2025 10:07:45 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[Baekjoon-11085]=20=EA=B5=B0=EC=82=AC=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\202\254 \354\235\264\353\217\231.java" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-11085] \352\265\260\354\202\254 \354\235\264\353\217\231.java" diff --git "a/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-11085] \352\265\260\354\202\254 \354\235\264\353\217\231.java" "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-11085] \352\265\260\354\202\254 \354\235\264\353\217\231.java" new file mode 100644 index 00000000..8babdc8b --- /dev/null +++ "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-11085] \352\265\260\354\202\254 \354\235\264\353\217\231.java" @@ -0,0 +1,68 @@ +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int p = Integer.parseInt(st.nextToken()); + int w = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + int s = Integer.parseInt(st.nextToken()); + int e = Integer.parseInt(st.nextToken()); + + List[] graph = new ArrayList[p]; + for(int i=0; i(); + } + + for(int i=0; i pq = new PriorityQueue<>((o1, o2) -> -Integer.compare(o1[1], o2[1])); + boolean[] visited = new boolean[p]; + pq.offer(new int[] {s, Integer.MAX_VALUE}); + + while(!pq.isEmpty()) { + int[] info = pq.poll(); + int current = info[0]; + + if(current == e) { + System.out.println(info[1]); + return; + } + + if(visited[current]) continue; + visited[current] = true; + + for(Edge edge : graph[current]) { + if(visited[edge.to]) continue; + pq.offer(new int[] {edge.to, Math.min(info[1], edge.weight)}); + } + } + + System.out.println(0); + } + + public static class Edge{ + int to; + int weight; + + public Edge(int to, int weight) { + this.to = to; + this.weight = weight; + } + } +} From 512c44aa49b918028cfc7c742037ae9af79b4070 Mon Sep 17 00:00:00 2001 From: Yoo Byeong gue <106210750+Gyulguma@users.noreply.github.com> Date: Mon, 19 May 2025 10:08:04 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[Baekjoon-8980]=20=ED=83=9D=EB=B0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[BOJ-8980] \355\203\235\353\260\260.java" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-8980] \355\203\235\353\260\260.java" diff --git "a/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-8980] \355\203\235\353\260\260.java" "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-8980] \355\203\235\353\260\260.java" new file mode 100644 index 00000000..c96f42c6 --- /dev/null +++ "b/\354\234\240\353\263\221\352\267\234_17\354\243\274\354\260\250/[BOJ-8980] \355\203\235\353\260\260.java" @@ -0,0 +1,55 @@ +import java.io.*; +import java.util.*; + +public class Main { + + 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 c = Integer.parseInt(st.nextToken()); + + List order = new ArrayList<>(); + + int m = Integer.parseInt(br.readLine()); + for(int i=0; i Integer.compare(o1[1], o2[1])); + + //트럭에 실은 박스들 + int[] village = new int[n+1]; + + //트럭 출발 + int result = 0; + for(int idx=0; idx