diff --git "a/BOJ/1000-5000353円262円210円/JY_1613.java" "b/BOJ/1000-5000353円262円210円/JY_1613.java" new file mode 100644 index 00000000..fee3423f --- /dev/null +++ "b/BOJ/1000-5000353円262円210円/JY_1613.java" @@ -0,0 +1,68 @@ +package day1113; + +import java.io.*; +import java.util.*; + +public class JY_1613 { + + static final int INF = 50_000; + + 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()); + + int[][] g = new int[N+1][N+1]; + for(int i=0; i j로 갈 수 있는 최단거리 구함 + for(int k=1; k 0) isDone = false; + } + + if(isDone) break; + + } + + printS(); + + } + public static void printG() { + for(int i=0; i 1) return false; + + // 기로즐 체크 + cnt = 0; + for(int j=0; j 1) return false; + + } + } + return true; + } + public static boolean checkBox(int n) { + // 유효한 3 * 3 찾기 + for(int i=0; i 1) return false; + if(cnt == 0 && empty == 0) return false; + } + } + return true; + } + public static boolean isValid(int n) { + visited = new boolean[N][N]; + + fillArea(n); + + return checkBox(n) && checkLine(n); + } + public static int findSpot(int n) { + // 유효한 3 * 3 찾기 + int fCnt = 0; + for(int i=0; i CrossHatching + if(cnt == 0 && empty == 1) { + visited[px][py] = true; + g[px][py] = n; + fillLine(px, py); + fCnt++; + } + } + } + return fCnt; + } + public static int crossHatching(int n) { + visited = new boolean[N][N]; + fillArea(n); + + + return findSpot(n); + } + +} diff --git "a/CodeTree/2019-2020353円205円204円/JY_355円232円214円354円240円204円355円225円230円353円212円224円_353円271円231円355円225円230円.java" "b/CodeTree/2019-2020353円205円204円/JY_355円232円214円354円240円204円355円225円230円353円212円224円_353円271円231円355円225円230円.java" new file mode 100644 index 00000000..d4a1cf4c --- /dev/null +++ "b/CodeTree/2019-2020353円205円204円/JY_355円232円214円354円240円204円355円225円230円353円212円224円_353円271円231円355円225円230円.java" @@ -0,0 +1,167 @@ +package day1111; + +import java.io.*; +import java.util.*; + +public class JY_회전하는_빙하 { + + static int n, N, Q; + static int[][] g, t; + static int[] dx = {0, 0, -1, 1}; + static int[] dy = {-1, 1, 0, 0}; + static boolean[][] visited; + + + 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()); + Q = Integer.parseInt(st.nextToken()); + + N = (int)Math.pow(2, n); + + g = new int[N][N]; + for(int i=0; i 0) { + int S = (int)Math.pow(2, r); + t = new int[N][N]; + + for(int i=0; i=0 && x=0 && y q = new LinkedList(); + q.add(new int[] {x, y}); + + while(!q.isEmpty()) { + int[] now = q.poll(); + + for(int i=0; i<4; i++) { + int nx = now[0] + dx[i]; + int ny = now[1] + dy[i]; + if(!inRange(nx, ny)) continue; + if(visited[nx][ny]) continue; + if(g[nx][ny] == 0) continue; + visited[nx][ny] = true; + q.add(new int[] {nx, ny}); + size++; + } + } + + return size; + } + +} diff --git a/Programmers/Level2/JY_181188.java b/Programmers/Level2/JY_181188.java new file mode 100644 index 00000000..c1e62a20 --- /dev/null +++ b/Programmers/Level2/JY_181188.java @@ -0,0 +1,27 @@ +import java.util.*; + +class Solution { + public int solution(int[][] targets) { + int answer = 0; + + // 시작점 기준으로 정렬 + Arrays.sort(targets, (o1, o2)->o1[0]-o2[0]); + + int N = targets.length; + int bound = 0; // 경계값 + for(int i=0; i= bound) { + answer++; + bound = e; + } else { + bound = Math.min(bound, e); // 현재 요격으로 가능한 모든 범위의 미사일을 없애야 하므로 범위가 가장 작은 미사일로 저장 + } + } + + return answer; + } +} \ No newline at end of file diff --git a/Programmers/Level3/JY_150366.java b/Programmers/Level3/JY_150366.java new file mode 100644 index 00000000..8d0053f8 --- /dev/null +++ b/Programmers/Level3/JY_150366.java @@ -0,0 +1,136 @@ +import java.util.*; + +class Solution { + + static final int N = 51; + static String[][] g; + static List[] link; + static List aList; + + public String[] solution(String[] commands) { + aList = new ArrayList(); + + g = new String[N][N]; + for(int i=0; i(); + } + + for(String c: commands) { + String[] crr = c.split(" "); + + // 1) UPDATE r c value + if(crr[0].equals("UPDATE") && crr.length == 4) { + insert(Integer.parseInt(crr[1]), Integer.parseInt(crr[2]), crr[3]); + } + // 2) UPDATE value1, value2 + else if (crr[0].equals("UPDATE") && crr.length == 3) { + change(crr[1], crr[2]); + } + // 3) MERGE r1 c1 r2 c2 + else if(crr[0].equals("MERGE")) { + merge(Integer.parseInt(crr[1]), + Integer.parseInt(crr[2]), + Integer.parseInt(crr[3]), + Integer.parseInt(crr[4])); + } + // 4) UNMERGE r c + else if(crr[0].equals("UNMERGE")) { + unmerge(Integer.parseInt(crr[1]), Integer.parseInt(crr[2])); + } + // 5) PRINT r c + else if(crr[0].equals("PRINT")) { + print(Integer.parseInt(crr[1]), Integer.parseInt(crr[2])); + } + + } + + // System.out.println(aList); + String[] answer = new String[aList.size()]; + for(int i=0; i q = new LinkedList(); + boolean[][] visited = new boolean[N][N]; + + q.add(r*N + c); + visited[r][c] = true; + + while(!q.isEmpty()) { + int now = q.poll(); + int x = now / N; + int y = now % N; + g[x][y] = v; + for(int next: link[now]) { + int nx = next / N; + int ny = next % N; + if(visited[nx][ny]) continue; + + visited[nx][ny] = true; + q.add(next); + } + if(isUnmerge) link[now] = new ArrayList(); + } + } + public static void insert(int r, int c, String v) { + g[r][c] = v; + + if(link[r*N+c].isEmpty()) return; + + linking(r, c, v, false); + } + public static void change(String v1, String v2) { + for(int i=0; io1[1]-o2[1]); + + int last = -30001; + for(int [] route: routes) { + if(route[0]> last) { + answer++; + last = route[1]; + } + } + + return answer; + } +} \ No newline at end of file diff --git "a/SQL/10354円243円274円354円260円250円/JY_Human_Traffic_of_Stadium.sql" "b/SQL/10354円243円274円354円260円250円/JY_Human_Traffic_of_Stadium.sql" new file mode 100644 index 00000000..eaa3fc89 --- /dev/null +++ "b/SQL/10354円243円274円354円260円250円/JY_Human_Traffic_of_Stadium.sql" @@ -0,0 +1,12 @@ +-- 601. Human Traffic of Stadium +-- https://leetcode.com/problems/human-traffic-of-stadium/ +WITH CTE AS( + SELECT *, ID- ROW_NUMBER() OVER() AS ID_DIFF + FROM STADIUM + WHERE PEOPLE> 99 +) + +SELECT ID, VISIT_DATE, PEOPLE +FROM CTE +WHERE ID_DIFF IN (SELECT ID_DIFF FROM CTE GROUP BY ID_DIFF HAVING COUNT(ID_DIFF)>= 3) +ORDER BY VISIT_DATE \ No newline at end of file diff --git "a/SQL/10354円243円274円354円260円250円/JY_355円212円271円354円240円225円_355円230円225円354円247円210円354円235円204円_352円260円200円354円247円200円353円212円224円_353円214円200円354円236円245円352円267円240円_354円260円276円352円270円260円.sql" "b/SQL/10354円243円274円354円260円250円/JY_355円212円271円354円240円225円_355円230円225円354円247円210円354円235円204円_352円260円200円354円247円200円353円212円224円_353円214円200円354円236円245円352円267円240円_354円260円276円352円270円260円.sql" new file mode 100644 index 00000000..d11d2311 --- /dev/null +++ "b/SQL/10354円243円274円354円260円250円/JY_355円212円271円354円240円225円_355円230円225円354円247円210円354円235円204円_352円260円200円354円247円200円353円212円224円_353円214円200円354円236円245円352円267円240円_354円260円276円352円270円260円.sql" @@ -0,0 +1,27 @@ +-- https://school.programmers.co.kr/learn/courses/30/lessons/301646 +-- 특정 형질을 가지는 대장균 찾기 + +-- 방법 1. 비트연산 활용 +-- 1) +SELECT COUNT(ID) AS COUNT +FROM ECOLI_DATA +WHERE (GENOTYPE & 2 != 2) AND (GENOTYPE & 1 = 1 OR GENOTYPE & 4 = 4) +-- 2) +SELECT COUNT(ID) AS COUNT +FROM ECOLI_DATA +WHERE (GENOTYPE & 2 != 2) AND (GENOTYPE & 5> 5) + +-- 방법 2. 2진수로 나타내기 +SELECT CONV(GENOTYPE, 10, 2) MOD 10 AS ONE, + (CONV(GENOTYPE, 10, 2) MOD 100) DIV 10 AS TWO, + (CONV(GENOTYPE, 10, 2) MOD 1000) DIV 100 AS THREE +FROM ECOLI_DATA + +SELECT COUNT(*) AS COUNT +FROM ECOLI_DATA E, + (SELECT CONV(GENOTYPE, 10, 2) MOD 10 AS ONE, + (CONV(GENOTYPE, 10, 2) MOD 100) DIV 10 AS TWO, + (CONV(GENOTYPE, 10, 2) MOD 1000) DIV 100 AS THREE, + ID + FROM ECOLI_DATA) G +WHERE E.ID = G.ID AND G.TWO = 0 AND (G.ONE = 1 OR G.THREE = 1); \ No newline at end of file

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