From 889944d72c01c17a14bc28413c3992000b791768 Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月20日 23:19:01 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201938?= =?UTF-8?q?=20=ED=86=B5=EB=82=98=EB=AC=B4=20=EC=98=AE=EA=B8=B0=EA=B8=B0=5F?= =?UTF-8?q?250120?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_1938.java" | 140 +++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_1938.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_1938.java" "b/BOJ/1000-5000353円262円210円/SB_1938.java" new file mode 100644 index 00000000..48c6988e --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_1938.java" @@ -0,0 +1,140 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class SB_1938 { + static int N; + static int[][] board; + static int[][][] visited; + static Node target; + static int[] dx = {-1, 1, 0, 0, 0}; + static int[] dy = {0, 0, -1, 1, 0}; + + private static int bfs(Node start) { + Queue que = new ArrayDeque(); + que.offer(start); + visited[start.x][start.y][start.ty] = 0; + + while (!que.isEmpty()) { + Node cur = que.poll(); + if (cur.x==target.x && cur.y== target.y && cur.ty== target.ty) return visited[cur.x][cur.y][cur.ty]; + + for (int i = 0; i < 5; i++) { + int nx = cur.x + dx[i]; + int ny = cur.y + dy[i]; + if (!isValid(nx, ny) || board[nx][ny]==1) continue; // 중심좌표가 범위 벗어나면 패쓰 + + if (i==4) { // 회전할때 경우 + int nt = cur.ty ^ 1; + if(canTurn(nx, ny, nt) && visited[nx][ny][nt]==-1) { + que.offer(new Node(nx, ny, nt)); + visited[nx][ny][nt] = visited[cur.x][cur.y][cur.ty] + 1; + } + continue; + } + + // 상하좌우로 움직인 nx,ny 값에 대해 가로,세로일때 각 양날개가 가능한지 체크 + if (cur.ty == 0 && canWingRow(nx, ny) && visited[nx][ny][cur.ty]==-1) { + que.offer(new Node(nx, ny, cur.ty)); + visited[nx][ny][cur.ty] = visited[cur.x][cur.y][cur.ty] + 1; + } else if (cur.ty == 1 && canWingCol(nx, ny) && visited[nx][ny][cur.ty]==-1) { + que.offer(new Node(nx, ny, cur.ty)); + visited[nx][ny][cur.ty] = visited[cur.x][cur.y][cur.ty] + 1; + } + } + } + return 0; + } + + private static boolean canWingRow(int r, int c) { // 가로일때 날개 유효한지 + return isValid(r, c-1) && isValid(r, c+1) && board[r][c - 1] == 0 && board[r][c + 1] == 0; + } + + private static boolean canWingCol(int r, int c) { // 세로일때 날개 유효한지 + return isValid(r-1, c) && isValid(r+1, c) && board[r-1][c] == 0 && board[r+1][c] == 0; + } + + private static boolean canTurn(int r, int c, int t) { + for (int i = r - 1; i <= r + 1; i++) { + for (int j = c - 1; j <= c + 1; j++) { + if (!isValid(i, j) || board[i][j]==1) return false; + } + } + return true; + } + + private static boolean isValid(int x, int y) { // 좌표 유효성 검사 + return 0<=x && x b = new ArrayList(); + List e = new ArrayList(); + for (int i=0; i { + if (o1[0] != o2[0]) return Integer.compare(o1[0], o2[0]); + return Integer.compare(o1[1], o2[1]); + }); + + Collections.sort(e, (o1, o2) -> { + if (o1[0] != o2[0]) return Integer.compare(o1[0], o2[0]); + return Integer.compare(o1[1], o2[1]); + }); + + // 처음 중심 좌표 및 형태 + int tb = (b.get(0)[0] == b.get(1)[0]) ? 0 : 1; // 가로(0), 세로(1) + int te = (e.get(0)[0] == e.get(1)[0]) ? 0 : 1; + Node start = new Node(b.get(1)[0], b.get(1)[1], tb); // 중간값이 중심값 + target = new Node(e.get(1)[0], e.get(1)[1], te); + + System.out.println(bfs(start)); + } + + static class Node{ + int x, y, ty; + + public Node(int x, int y, int ty) { + this.x = x; + this.y = y; + this.ty = ty; + } + + @Override + public String toString() { + return "Node{" + + "x=" + x + + ", y=" + y + + ", ty=" + ty + + '}'; + } + } + +} From 2a6000efe4eff9bf4b7e01315f685aeb481120cf Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月22日 23:52:45 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201333?= =?UTF-8?q?4=20=EC=B2=A0=EB=A1=9C=5F250122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/10001-15000353円262円210円/SB_13334.java" | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "BOJ/10001-15000353円262円210円/SB_13334.java" diff --git "a/BOJ/10001-15000353円262円210円/SB_13334.java" "b/BOJ/10001-15000353円262円210円/SB_13334.java" new file mode 100644 index 00000000..c89bb183 --- /dev/null +++ "b/BOJ/10001-15000353円262円210円/SB_13334.java" @@ -0,0 +1,52 @@ +package PriorityQueue; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.PriorityQueue; +import java.util.StringTokenizer; + +public class SB_13334 { + static int N, d; + static PriorityQueue pq = new PriorityQueue(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + N = Integer.parseInt(br.readLine()); + for (int i = 0; i < N; i++) { + st = new StringTokenizer(br.readLine()); + int s = Integer.parseInt(st.nextToken()); + int e = Integer.parseInt(st.nextToken()); + pq.offer(new Node(Math.min(s, e), Math.max(s, e))); // 집과 사무실 중 작은게 시작, 큰게 끝 + } + d = Integer.parseInt(br.readLine()); + + PriorityQueue pre = new PriorityQueue(); // 이전 사람들의 정보를 저장하는 우선순위 큐 + int mx = 0; + while (!pq.isEmpty()) { + Node cur = pq.poll(); + int start = cur.e - d; // 철로의 시작 지점 + pre.offer(cur.s); // 현재 노드의 시작지점을 pre큐에 넣어주기 + while (!pre.isEmpty() && pre.peek() < start) { // 이전 사람들이 현재 철로에 속하지 못하면 빼주기 + pre.poll(); + } + mx = Math.max(mx, pre.size()); + } + + System.out.println(mx); + } + + static class Node implements Comparable{ + int s, e; + + public Node(int s, int e) { + this.s = s; + this.e = e; + } + @Override + public int compareTo(Node o) { + if (this.e-o.e!=0) return this.e - o.e; + return this.s-o.s; + } + } +} From 8f5d8696020dc9a64a09c4f8c6cd0ca5f3a58957 Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月23日 21:54:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201405?= =?UTF-8?q?=20=EB=AF=B8=EC=B9=9C=20=EB=A1=9C=EB=B4=87=5F250123?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_1405.java" | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_1405.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_1405.java" "b/BOJ/1000-5000353円262円210円/SB_1405.java" new file mode 100644 index 00000000..5b815e35 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_1405.java" @@ -0,0 +1,44 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class SB_1405 { + static int N; + static int[] dx = {0, 0, 1, -1}; // 동, 서, 남, 북 + static int[] dy = {1, -1, 0, 0}; + static double[] prob = new double[4]; + static boolean[][] visited = new boolean[30][30]; + static double ans = 0; + + private static void dfs(int x, int y, int depth, double total) { + if (depth==N) { + ans += total; + return; + } + + for (int i = 0; i < 4; i++) { + int nx = x + dx[i]; + int ny = y + dy[i]; + if (!visited[nx][ny]){ // 방문하지 않은 곳이라면 + visited[nx][ny] = true; + dfs(nx, ny, depth+1, total*prob[i]); + visited[nx][ny] = false; + } + } + } + + 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()); + for (int i = 0; i < 4; i++) { + prob[i] = Integer.parseInt(st.nextToken())*0.01; // 확률로 표현 + } + + visited[15][15] = true; + dfs(15, 15, 0, 1); + System.out.println(ans); + } +} From 46fee428fc2cc634904038d42500aa0f9f8a35ad Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月23日 23:50:29 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=20Imme?= =?UTF-8?q?diate=20Food=20Delivery=20II?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SB_Immediate Food Delivery II.sql" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "SQL/19354円243円274円354円260円250円/SB_Immediate Food Delivery II.sql" diff --git "a/SQL/19354円243円274円354円260円250円/SB_Immediate Food Delivery II.sql" "b/SQL/19354円243円274円354円260円250円/SB_Immediate Food Delivery II.sql" new file mode 100644 index 00000000..6b0a5fcb --- /dev/null +++ "b/SQL/19354円243円274円354円260円250円/SB_Immediate Food Delivery II.sql" @@ -0,0 +1,7 @@ +SELECT ROUND(AVG(order_date = customer_pref_delivery_date)*100,2) as immediate_percentage +FROM Delivery +WHERE (customer_id, order_date) in ( + SELECT customer_id, min(order_date) + FROM Delivery + GROUP BY customer_id +) \ No newline at end of file From 58179f4cba94a939dae960b54dc2a13e09c6dbbb Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月24日 17:01:51 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201256?= =?UTF-8?q?=20=EC=82=AC=EC=A0=84=5F250124?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_1256.java" | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_1256.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_1256.java" "b/BOJ/1000-5000353円262円210円/SB_1256.java" new file mode 100644 index 00000000..b2f8e535 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_1256.java" @@ -0,0 +1,68 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class SB_1256 { + static int N, M, K; + static long[][] dp; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + StringBuilder sb = new StringBuilder(); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + K = Integer.parseInt(st.nextToken()); + + dp = new long[N+1][M+1]; + + // dp배열 만들기 + dp[0][0] = 1; // 아무것도 못만드는 경우 1개 + for (int i = 1; i <= N; i++) { // a만으로 이루어진 경우 + dp[i][0] = 1; + } + for (int j = 1; j <= M; j++) { // z만으로 이루어진 경우 + dp[0][j] = 1; + } + + for (int i = 1; i <= N; i++) { + for (int j = 1; j <= M; j++) { + dp[i][j] = Math.min(dp[i - 1][j] + dp[i][j - 1], K); // a를 앞에 추가해서 만들기 + z를 앞에 추가해서 만들기 + } + } + + // K가 범위 벗어나면 -1 + if (dp[N][M] < K) { + System.out.println(-1); + return; + } + + // 사전순으로 문자열 만들기 + while (N> 0 && M> 0) { + long tmp = dp[N - 1][M]; // a로 시작하는 문자열의 개수 + if (K <= tmp) { // K가 tmp(a로 시작하는 범위의 개수)에 속할경우 + N -= 1; // 현재 tmp에서 N=-1해서 다음 경우 살피기 (현재 자리값 고정, 다음 자리 확인) + sb.append('a'); // a로 시작하기에 a붙이기 + } else { // K가 tmp보다 클 경우 z를 시작으로하는 범위에서 살피기 + M -= 1; // M=-1해서 다음 경우 살피기 + K -= tmp; // K에서 제외된 tmp값 빼주기 + sb.append('z'); // z로 시작하기에 z붙이기 + } + } + + // 남은 문자 처리 + while (N> 0) { + sb.append('a'); + N--; + } + + while (M> 0) { + sb.append('z'); + M--; + } + + System.out.println(sb); + + } +}

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