From 338d3e0a3dde3b0ac63e36362b08e3bfa2fd6797 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Tue, 7 Jan 2025 10:34:14 +0900 Subject: [PATCH 1/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=203109?= =?UTF-8?q?=20=EB=B9=B5=EC=A7=91=5F250107?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_3109.java" | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_3109.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_3109.java" "b/BOJ/1000-5000353円262円210円/SB_3109.java" new file mode 100644 index 00000000..82753673 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_3109.java" @@ -0,0 +1,50 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class SB_3109 { + static int R, C; + static char[][] board; + static boolean[][] visited; + static int[] dx = {-1, 0, 1}; + static int[] dy = {1, 1, 1}; + + private static boolean backtracking(int r, int c) { + if (c == C - 1) return true; + + for (int i = 0; i < 3; i++) { + int nr = r + dx[i]; + int nc = c + dy[i]; + if (!isValid(nr, nc) || board[nr][nc]=='x' || visited[nr][nc]) continue; + visited[nr][nc] = true; + if (backtracking(nr, nc)) return true; // 그냥 함수값을 바로 리턴하면 실패했을때 더 못돌아봄 + } + return false; + } + + private static boolean isValid(int x, int y) { + return 0 <= x && x < R && 0 <= y && y < C; + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + R = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + + board = new char[R][C]; + visited = new boolean[R][C]; + for (int i = 0; i < R; i++) { + String line = br.readLine(); + for (int j = 0; j < C; j++) { + board[i][j] = line.charAt(j); + } + } + + int ans = 0; + for (int r = 0; r < R; r++) { + if(backtracking(r, 0)) ans++; + } + System.out.println(ans); + } +} From 871f00ed27e86a8cecea1ae5f9b5bbbafa0904ff Mon Sep 17 00:00:00 2001 From: baexxbin Date: Tue, 7 Jan 2025 11:31:31 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=20Mana?= =?UTF-8?q?gers=20with=20at=20Least=205=20Direct=20Reports=5F250507?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SB_Managers with at Least 5 Direct Reports.sql" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "SQL/17354円243円274円354円260円250円/SB_Managers with at Least 5 Direct Reports.sql" diff --git "a/SQL/17354円243円274円354円260円250円/SB_Managers with at Least 5 Direct Reports.sql" "b/SQL/17354円243円274円354円260円250円/SB_Managers with at Least 5 Direct Reports.sql" new file mode 100644 index 00000000..b589793d --- /dev/null +++ "b/SQL/17354円243円274円354円260円250円/SB_Managers with at Least 5 Direct Reports.sql" @@ -0,0 +1,8 @@ +# Write your MySQL query statement below +# 최소 5명의 직속 부하 직원이 있는 관리자를 찾기 + +SELECT a.name AS name +FROM Employee a +JOIN Employee b ON a.id = b.managerId +GROUP BY a.id, a.name +HAVING COUNT(b.id)>= 5; \ No newline at end of file From b826a7941664165374ff55698f4e6a320d388f41 Mon Sep 17 00:00:00 2001 From: baexxbin Date: Wed, 8 Jan 2025 10:52:41 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[PG]=2086052?= =?UTF-8?q?=20=EB=B9=9B=EC=9D=98=20=EA=B2=BD=EB=A1=9C=20=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=ED=81=B4=5F250108?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354円202円254円354円235円264円355円201円264円.java" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "Programmers/Level2/SB_353円271円233円354円235円230円352円262円275円353円241円234円354円202円254円354円235円264円355円201円264円.java" diff --git "a/Programmers/Level2/SB_353円271円233円354円235円230円352円262円275円353円241円234円354円202円254円354円235円264円355円201円264円.java" "b/Programmers/Level2/SB_353円271円233円354円235円230円352円262円275円353円241円234円354円202円254円354円235円264円355円201円264円.java" new file mode 100644 index 00000000..50bd36cd --- /dev/null +++ "b/Programmers/Level2/SB_353円271円233円354円235円230円352円262円275円353円241円234円354円202円254円354円235円264円355円201円264円.java" @@ -0,0 +1,58 @@ +import java.util.ArrayList; +import java.util.Collections; + + +public class SB_빛의경로사이클 { + static int N, M; + static boolean[][][] visited; + static char[][] board; + static ArrayList ans = new ArrayList(); + static int[] dx = {-1, 0, 1, 0}; // 상우하좌 + static int[] dy = {0, 1, 0, -1}; + + private static int shootLight(int i, int j, int d) { + int cnt = 0; + + while (!visited[i][j][d]) { // 사이클을 만들기전까지 반복 + visited[i][j][d] = true; + cnt++; + + // 현재 위치에 따른 방향 변환 + if (board[i][j]=='L') d = (d + 3) % 4; + else if (board[i][j]=='R') d = (d + 1) % 4; + + // 다음 위치 이동 + int nx = (i + dx[d] + N) % N; + int ny = (j + dy[d] + M) % M; + i = nx; + j = ny; + } + return cnt; + } + public static int[] solution(String[] grid) { + N = grid.length; + M = grid[0].length(); + visited = new boolean[N][M][4]; + board = new char[N][M]; + + // char배열로 그리드 변환 + for (int i = 0; i < N; i++) { + String row = grid[i]; + for (int j = 0; j < M; j++) { + board[i][j] = row.charAt(j); + } + } + + // 방문하지 않은 곳과 쏘아보지 않은 빛 방향일때 빛 쏘기 + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + for (int d = 0; d < 4; d++) { + if (!visited[i][j][d]) ans.add(shootLight(i, j, d)); + } + } + } + + Collections.sort(ans); + return ans.stream().mapToInt(Integer::intValue).toArray(); + } +} From 2db29c1e80b4bb17e7e8005a6a5b319e53bfd8f6 Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月10日 09:55:11 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[PG]=2012905?= =?UTF-8?q?=20=EA=B0=80=EC=9E=A5=20=ED=81=B0=20=EC=A0=95=EC=82=AC=EA=B0=81?= =?UTF-8?q?=ED=98=95=20=EC=B0=BE=EA=B8=B0=5F250110?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level2/SB_12905.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Programmers/Level2/SB_12905.java diff --git a/Programmers/Level2/SB_12905.java b/Programmers/Level2/SB_12905.java new file mode 100644 index 00000000..439bb8e8 --- /dev/null +++ b/Programmers/Level2/SB_12905.java @@ -0,0 +1,27 @@ +public class SB_12905 { + public int solution(int [][]board) { + int N = board.length; + int M = board[0].length; + + int[][] dp = new int[N][M]; + + // dp배열 초기화 + int len = 0; + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + dp[i][j] = board[i][j]; + if (dp[i][j]==1) len = 1; + } + } + + for (int i = 1; i < N; i++) { + for (int j = 1; j < M; j++) { + if (board[i][j]==0) continue; + dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1; + len = Math.max(len, dp[i][j]); + } + } + + return len*len; + } +} From f91f4f78e30f91c84afcc36ea6ac409cbdb0546f Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月10日 10:19:43 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[SQL]=20Sale?= =?UTF-8?q?s=20Analysis=20III=5F250110?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../17354円243円274円354円260円250円/SB_Sales Analysis III.sql" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "SQL/17354円243円274円354円260円250円/SB_Sales Analysis III.sql" diff --git "a/SQL/17354円243円274円354円260円250円/SB_Sales Analysis III.sql" "b/SQL/17354円243円274円354円260円250円/SB_Sales Analysis III.sql" new file mode 100644 index 00000000..f5e8a1f2 --- /dev/null +++ "b/SQL/17354円243円274円354円260円250円/SB_Sales Analysis III.sql" @@ -0,0 +1,8 @@ +# Write your MySQL query statement below +# 2019년 첫번째 분기에만 팔린 상품 고르기 + +SELECT p.product_id, p.product_name +FROM Product p +JOIN Sales s ON p.product_id = s.product_id +GROUP BY p.product_id +HAVING MIN(sale_date)>= '2019-01-01' AND MAX(sale_date) <= '2019-03-31'; \ No newline at end of file From d2509eb0a9e6ca8b5a5d4bb2cf19dd371a6bd322 Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月10日 22:36:28 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=202006?= =?UTF-8?q?1=20=EB=AA=A8=EB=85=B8=EB=AF=B8=EB=85=B8=EB=8F=84=EB=AF=B8?= =?UTF-8?q?=EB=85=B8=202=5F250110?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/20001-25000353円262円210円/SB_20061.java" | 256 ++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 "BOJ/20001-25000353円262円210円/SB_20061.java" diff --git "a/BOJ/20001-25000353円262円210円/SB_20061.java" "b/BOJ/20001-25000353円262円210円/SB_20061.java" new file mode 100644 index 00000000..0ac0535f --- /dev/null +++ "b/BOJ/20001-25000353円262円210円/SB_20061.java" @@ -0,0 +1,256 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class SB_20061 { + static boolean[][] bBoard = new boolean[4][6]; + static boolean[][] gBoard = new boolean[6][4]; + static int ans = 0; + + private static void putBlueBlock(Block b) { + // 행 고정, 열 움직이기 + int targetCol = -1; + for (int c = 0; c < 6; c++) { + boolean canPlace = true; + for (int i = 0; i < b.sr; i++) { // 블럭의 세로 크기만큼 확인 + for (int j = 0; j < b.sc; j++) { // 블럭의 가로 크기만큼 확인 + if (c + j> 5 || bBoard[b.r + i][c + j]) { // 블럭을 놓을 수 없을 경우(범위 벗어나거나 겹침) + canPlace = false; + break; + } + } + if (!canPlace) break; // 현재 행 불가능이면 끝 + } + + if (canPlace) targetCol = c; // 현재 위치가 블록을 놓을 수 있으면 targetCol 최신 현재 위치로 업데이트 + else break; // 블록을 더이상 못놓으면 탈출 + } + + // 블록을 targetCol에 놓기 + if (targetCol != -1) { + for (int i = 0; i < b.sr; i++) { + for (int j = 0; j < b.sc; j++) { + bBoard[b.r + i][targetCol + j] = true; + } + } + } + } + + private static void putGreenBlock(Block b) { + // 열 고정, 행 움직이기 + int targetRow = -1; + for (int r = 0; r < 6; r++) { + boolean canPlace = true; + for (int i = 0; i < b.sr; i++) { + for (int j = 0; j < b.sc; j++) { + if (r + i> 5 || gBoard[r + i][b.c + j]) { + canPlace = false; + break; + } + } + if (!canPlace) break; + } + if (canPlace) targetRow = r; + else break; + } + + if (targetRow != -1) { + for (int i = 0; i < b.sr; i++) { + for (int j = 0; j < b.sc; j++) { + gBoard[targetRow + i][b.c + j] = true; + } + } + } + } + + private static int removeBlock() { // 꽉찬 행, 열 터치기 + int score = 0; + + // 파란보드 (열 지우기) + for (int c = 5; c>= 0; c--) { + if (isColFull(c)) { + removeCol(c); + c++; // 열 제거후 이전 열이 지워진 열로 이동하기에, 같은열 다시 확인 + score++; + } + } + + // 초록보드 (행 지우기) + for (int r = 5; r>= 0; r--) { + if (isRowFull(r)) { + removeRow(r); + r++; + score++; + } + } + + return score; + } + + private static boolean isColFull(int c) { + for (int r = 0; r < 4; r++) { + if (!bBoard[r][c]) return false; + } + return true; + } + + private static void removeCol(int c) { + // 터질 열을 기준으로 왼쪽에서 한열씩 이동 + for (int j = c; j>0; j--) { + for (int i = 0; i < 4; i++) { + bBoard[i][j] = bBoard[i][j-1]; + } + } + + // 제일 끝 열(0열) 새 열로 초기화 + for (int r = 0; r < 4; r++) { + bBoard[r][0] = false; + } + } + + + private static boolean isRowFull(int r) { + for (int c = 0; c < 4; c++) { + if (!gBoard[r][c]) return false; + } + return true; + } + + private static void removeRow(int r) { + // 터질 행 위에서 아래로 한 행씩 이동 + for (int i = r; i> 0; i--) { + for (int j = 0; j < 4; j++) { + gBoard[i][j] = gBoard[i - 1][j]; + } + } + + // 제일 처음 행(0행) 초기화 + for (int c = 0; c < 4; c++) { + gBoard[0][c] = false; + } + } + + private static void pushLight() { + // 연한 파랑 처리 + int cnt1 = 0; + for (int c = 0; c < 2; c++) { + for (int r = 0; r < 4; r++) { + if (bBoard[r][c]) { + cnt1++; + break; + } + } + } + + while (cnt1--> 0) { + removeCol(5); + } + + + // 연한 초록 처리 + int cnt2 = 0; + for (int r = 0; r < 2; r++) { + for (int c = 0; c < 4; c++) { + if (gBoard[r][c]) { + cnt2++; + break; + } + } + } + + while (cnt2--> 0) { + removeRow(5); + } + } + + private static int calBlock() { + int cnt = 0; + + // 파란 보드 값 세기 + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 6; j++) { + if(bBoard[i][j]) cnt++; + } + } + + // 초록 보드 값 세기 + for (int i = 0; i < 6; i++) { + for (int j = 0; j < 4; j++) { + if(gBoard[i][j]) cnt++; + } + } + return cnt; + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + int N = Integer.parseInt(br.readLine()); + while (N--> 0) { + st = new StringTokenizer(br.readLine()); + int t = Integer.parseInt(st.nextToken()); + int x = Integer.parseInt(st.nextToken()); + int y = Integer.parseInt(st.nextToken()); + + Block block = new Block(x, y, t); + + // 블럭 놓기 + putBlueBlock(block); + putGreenBlock(block); + + // 타일 가득찬 블록 없애기 + ans += removeBlock(); + + // 연한 칸 블록 처리 + pushLight(); + } + + // 점수 계산 + sb.append(ans).append('\n').append(calBlock()); + System.out.println(sb); + } + + static private void print(boolean[][] board) { + StringBuilder sb = new StringBuilder(); + for (boolean[] b : board) { + sb.append(Arrays.toString(b)).append('\n'); + } + System.out.println(sb); + } + + static class Block{ + int r, c, sr, sc; // 좌표 위치, 블럭 사이즈 + + public Block(int r, int c, int type) { + this.r = r; + this.c = c; + switch (type) { + case 1: + this.sr = 1; + this.sc = 1; + break; + case 2: + this.sr = 1; + this.sc = 2; + break; + case 3: + this.sr = 2; + this.sc = 1; + break; + } + } + + @Override + public String toString() { + return "Block{" + + "r=" + r + + ", c=" + c + + ", sr=" + sr + + ", sc=" + sc + + '}'; + } + } +} From 13cf7698b8d4297d0e5fc6fa3abecd29e78bbfc2 Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月11日 23:20:45 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[PG]=2025871?= =?UTF-8?q?1=20=EB=8F=84=EB=84=9B=EA=B3=BC=20=EB=A7=89=EB=8C=80=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=ED=94=84=5F250111?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Level2/SB_258711.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Programmers/Level2/SB_258711.java diff --git a/Programmers/Level2/SB_258711.java b/Programmers/Level2/SB_258711.java new file mode 100644 index 00000000..b1ff12c7 --- /dev/null +++ b/Programmers/Level2/SB_258711.java @@ -0,0 +1,30 @@ +import java.util.HashMap; + +public class SB_258711 { + static HashMap graph = new HashMap(); + + private static void cntInOutLink(int node, int type) { + int[] cnt = graph.getOrDefault(node, new int[]{0, 0}); // cnt[0]: 진출차수, cnt[1]: 진입차수 + cnt[type]++; // 해당하는 타입 값++ + graph.put(node, cnt); + } + public static int[] solution(int[][] edges) { + int[] ans = {0, 0, 0, 0}; + + // 노드들의 진입,진출 차수 세기 + for (int[] e : edges) { + cntInOutLink(e[0], 0); // 나가는 간선 + cntInOutLink(e[1], 1); // 들어오는 간선 + } + + for (Integer key : graph.keySet()) { + int[] degree = graph.get(key); + if (degree[0]>=2 && degree[1]==0) ans[0] = key; // 생성 정점 + else if (degree[0]==0 && degree[1]> 0) ans[2]++; // 막대 그래프 + else if (degree[0]>=2 && degree[1]>=2) ans[3]++; // 8자 그래프 + } + ans[1] = graph.get(ans[0])[0] - ans[2] - ans[3]; + + return ans; + } +} From d864011cd1ba70cb9f86acfcb167ac54d725cfbc Mon Sep 17 00:00:00 2001 From: baexxbin Date: 2025年1月12日 09:09:05 +0900 Subject: [PATCH 8/8] =?UTF-8?q?=EB=B0=B0=EC=88=98=EB=B9=88:=20[BOJ]=201765?= =?UTF-8?q?=20=EB=8B=AD=EC=8B=B8=EC=9B=80=20=ED=8C=80=EC=A0=95=ED=95=98?= =?UTF-8?q?=EA=B8=B0=5F250112?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BOJ/1000-5000353円262円210円/SB_1765.java" | 81 ++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 "BOJ/1000-5000353円262円210円/SB_1765.java" diff --git "a/BOJ/1000-5000353円262円210円/SB_1765.java" "b/BOJ/1000-5000353円262円210円/SB_1765.java" new file mode 100644 index 00000000..6313cb82 --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/SB_1765.java" @@ -0,0 +1,81 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashSet; +import java.util.Set; +import java.util.StringTokenizer; + +public class SB_1765 { + static int N, M; + static int[] team, enemy; + + private static int find(int x) { + if (team[x]!=x) team[x] = find(team[x]); + return team[x]; + } + + private static void union(int a, int b) { + int pa = find(a); + int pb = find(b); + if (pa < pb) team[pb] = pa; + else if (pb < pa) team[pa] = pb; + } + + private static void makeRelation(char op, int p, int q) { + int pp = find(p); + int pq = find(q); + + if (pp == pq) return; + + if (op=='F'){ // 친구일 경우 팀 병합 + union(pp, pq); + + // 팀 병합에 따른 원수 관계 병합 + if (enemy[pp] != 0 && enemy[pq] != 0) union(enemy[pp], enemy[pq]); // 두 팀 모두 원수가 있으면 각 원수들끼리 친구 시키기 + + // 한 쪽만 원수 있으면 같이 원수 만들기 + else if (enemy[pp]!=0) enemy[pq] = find(enemy[pp]); + else if(enemy[pq]!=0) enemy[pp] = find(enemy[pq]); + } + else { // 원수일 경우, 각 팀의 원수를 상대랑 친구시키기 + if (enemy[pp]==0) enemy[pp] = pq; // pp의 원수가 없으면 pp의 원수는 바로 pq의 원수가 됨 + else union(enemy[pp], pq); // pp의 원수가 있으면 pp의 원수랑 pq랑 친구가 됨 + + if (enemy[pq]==0) enemy[pq] = pp; // 원수가 없으면 상대의 원수를 같이 원수로 받아드리고 + else union(enemy[pq], pp); // 원수가 있으면 나의 원수와 상대가 친구가됨 + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + N = Integer.parseInt(br.readLine()); + M = Integer.parseInt(br.readLine()); + + // 팀 초기화 + team = new int[N + 1]; + for (int i = 0; i < N + 1; i++) { + team[i] = i; + } + enemy = new int[N + 1]; + + for (int i = 0; i < M; i++) { + st = new StringTokenizer(br.readLine()); + char op = st.nextToken().charAt(0); + int p = Integer.parseInt(st.nextToken()); + int q = Integer.parseInt(st.nextToken()); + + makeRelation(op, p, q); + } + + + // 부모 재정비 + for (int i = 1; i <= N; i++) find(i); + + Set ans = new HashSet(); + for (int i = 1; i < N + 1; i++) { + ans.add(find(i)); + } + System.out.println(ans.size()); + } +}

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