From 57f90a8c94ea7e2c808e0fed40effa5809077459 Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 5 Jun 2025 18:30:39 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[BOJ-2637]=20=EC=9E=A5=EB=82=9C=EA=B0=90=20?= =?UTF-8?q?=EC=A1=B0=EB=A6=BD.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\352\260\220 \354\241\260\353\246\275.md" | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 "[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" diff --git "a/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" "b/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" new file mode 100644 index 0000000..7a12b3d --- /dev/null +++ "b/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" @@ -0,0 +1,84 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M; + static int[][] A; + static List[] V; + static int[] deg; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + A = new int[N+1][N+1]; + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + deg = new int[N+1]; + for(int i=0;i Q = new LinkedList<>(); + for(int i=1;i<=N;i++) if(isBasic[i]) { + for(int[] j:V[i]) { + int x = j[0], c = j[1]; + if(isBasic[i]) A[x][i] = c; + if(--deg[x] == 0) Q.offer(x); + } + } + + while(!Q.isEmpty()) { + int now = Q.poll(); + for(int[] j:V[now]) { + int x = j[0], c = j[1]; + for(int i=1;i<=N;i++) if(isBasic[i]) A[x][i] += A[now][i] * c; + if(--deg[x] == 0) Q.offer(x); + } + } + + for(int i=1;i<=N;i++) if(A[N][i] != 0) { + bw.write(i + " " + A[N][i] + "\n"); + } + + } + +} +``` From ce2812c4f2cd112be1fb7216442ccdb429eb0b1e Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 5 Jun 2025 18:31:03 +0900 Subject: [PATCH 2/7] =?UTF-8?q?Delete=20[BOJ-2637]=20=EC=9E=A5=EB=82=9C?= =?UTF-8?q?=EA=B0=90=20=EC=A1=B0=EB=A6=BD.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\352\260\220 \354\241\260\353\246\275.md" | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100644 "[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" diff --git "a/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" "b/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" deleted file mode 100644 index 7a12b3d..0000000 --- "a/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" +++ /dev/null @@ -1,84 +0,0 @@ -```java -import java.util.*; -import java.io.*; - -public class Main { - - // IO field - static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); - static StringTokenizer st = new StringTokenizer(""); - - static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} - static String nextToken() throws Exception { - while(!st.hasMoreTokens()) nextLine(); - return st.nextToken(); - } - static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } - static long nextLong() throws Exception { return Long.parseLong(nextToken()); } - static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } - static void bwEnd() throws Exception {bw.flush();bw.close();} - - // Additional field - - static int N, M; - static int[][] A; - static List[] V; - static int[] deg; - - public static void main(String[] args) throws Exception { - - ready(); - solve(); - - bwEnd(); - - } - - static void ready() throws Exception{ - - N = nextInt(); - M = nextInt(); - A = new int[N+1][N+1]; - V = new List[N+1]; - for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); - deg = new int[N+1]; - for(int i=0;i Q = new LinkedList<>(); - for(int i=1;i<=N;i++) if(isBasic[i]) { - for(int[] j:V[i]) { - int x = j[0], c = j[1]; - if(isBasic[i]) A[x][i] = c; - if(--deg[x] == 0) Q.offer(x); - } - } - - while(!Q.isEmpty()) { - int now = Q.poll(); - for(int[] j:V[now]) { - int x = j[0], c = j[1]; - for(int i=1;i<=N;i++) if(isBasic[i]) A[x][i] += A[now][i] * c; - if(--deg[x] == 0) Q.offer(x); - } - } - - for(int i=1;i<=N;i++) if(A[N][i] != 0) { - bw.write(i + " " + A[N][i] + "\n"); - } - - } - -} -``` From 5cba3868a337917b3c9fdc262e773a16e0e809c3 Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 5 Jun 2025 18:31:28 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[BOJ-2637]=20=EC=9E=A5=EB=82=9C=EA=B0=90=20?= =?UTF-8?q?=EC=A1=B0=EB=A6=BD.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\352\260\220 \354\241\260\353\246\275.md" | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" diff --git "a/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" new file mode 100644 index 0000000..7a12b3d --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2637] \354\236\245\353\202\234\352\260\220 \354\241\260\353\246\275.md" @@ -0,0 +1,84 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M; + static int[][] A; + static List[] V; + static int[] deg; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + A = new int[N+1][N+1]; + V = new List[N+1]; + for(int i=1;i<=N;i++) V[i] = new ArrayList<>(); + deg = new int[N+1]; + for(int i=0;i Q = new LinkedList<>(); + for(int i=1;i<=N;i++) if(isBasic[i]) { + for(int[] j:V[i]) { + int x = j[0], c = j[1]; + if(isBasic[i]) A[x][i] = c; + if(--deg[x] == 0) Q.offer(x); + } + } + + while(!Q.isEmpty()) { + int now = Q.poll(); + for(int[] j:V[now]) { + int x = j[0], c = j[1]; + for(int i=1;i<=N;i++) if(isBasic[i]) A[x][i] += A[now][i] * c; + if(--deg[x] == 0) Q.offer(x); + } + } + + for(int i=1;i<=N;i++) if(A[N][i] != 0) { + bw.write(i + " " + A[N][i] + "\n"); + } + + } + +} +``` From 550d45006022be50b7adc1288122dad6a65d220b Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 5 Jun 2025 18:32:09 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[BOJ-21276]=20=EA=B3=84=EB=B3=B4=20?= =?UTF-8?q?=EB=B3=B5=EC=9B=90=EA=B0=80=20=ED=98=B8=EC=84=9D.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\352\260\200 \355\230\270\354\204\235.md" | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-21276] \352\263\204\353\263\264 \353\263\265\354\233\220\352\260\200 \355\230\270\354\204\235.md" diff --git "a/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-21276] \352\263\204\353\263\264 \353\263\265\354\233\220\352\260\200 \355\230\270\354\204\235.md" "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-21276] \352\263\204\353\263\264 \353\263\265\354\233\220\352\260\200 \355\230\270\354\204\235.md" new file mode 100644 index 0000000..ef39478 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-21276] \352\263\204\353\263\264 \353\263\265\354\233\220\352\260\200 \355\230\270\354\204\235.md" @@ -0,0 +1,95 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M; + static TreeMap> V; + static TreeMap> R; + static TreeMap D; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception { + + N = nextInt(); + V = new TreeMap<>(); + D = new TreeMap<>(); + R = new TreeMap<>(); + for(int i=1;i<=N;i++) { + String a = nextToken(); + V.put(a, new ArrayList<>()); + R.put(a, new ArrayList<>()); + D.put(a, 0); + } + + for(M = nextInt(); M-->0;){ + String a = nextToken(), b = nextToken(); + V.get(b).add(a); + D.put(a, D.get(a) + 1); + } + + } + + static void solve() throws Exception { + + List roots = new ArrayList<>(); + TreeMap Z = new TreeMap<>(); + for(String key : D.keySet()) Z.put(key, D.get(key) == 0); + + for(String key : D.keySet()) if(Z.get(key)) { + roots.add(key); + Queue Q = new LinkedList<>(); + Q.offer(key); + while(!Q.isEmpty()) { + String n = Q.poll(); + for(String i : V.get(n)) { + D.put(i, D.get(i) - 1); + if(D.get(i) == 0) { + R.get(n).add(i); + Q.offer(i); + } + } + } + } + bw.write(roots.size() + "\n"); + for(String i:roots) bw.write(i + " "); + bw.write("\n"); + + for(String key:R.keySet()) { + bw.write(key + " " + R.get(key).size() + " "); + Collections.sort(R.get(key)); + for(String i:R.get(key)) bw.write(i + " "); + bw.write("\n"); + } + + + } + +} +``` From 412d9ef1ce4626090f68ee82bd73ae1dbea10899 Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 5 Jun 2025 18:32:42 +0900 Subject: [PATCH 5/7] [BOJ-25381] ABBC.md --- .../[BOJ-25381] ABBC.md" | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-25381] ABBC.md" diff --git "a/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-25381] ABBC.md" "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-25381] ABBC.md" new file mode 100644 index 0000000..10528c2 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-25381] ABBC.md" @@ -0,0 +1,76 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static List A, B, C; + static boolean[] RB; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception { + + A = new ArrayList<>(); + B = new ArrayList<>(); + C = new ArrayList<>(); + char[] temp = nextToken().toCharArray(); + for(int i=0;i C.get(j)) j++; + if(j < C.size()) { + ans++; + RB[i] = true; + j++; + } + } + + for(int i=0, j=0;i B.get(j))) j++; + if(j < B.size()) { + ans++; + j++; + } + } + + bw.write(ans + "\n"); + + } + +} +``` From 966862c976fb09ec3f087ce8fd920d3f773e188d Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 5 Jun 2025 18:33:13 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[BOJ-6209]=20=EC=A0=9C=EC=9E=90=EB=A6=AC=20?= =?UTF-8?q?=EB=A9=80=EB=A6=AC=EB=9B=B0=EA=B8=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...00\353\246\254\353\233\260\352\270\260.md" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-6209] \354\240\234\354\236\220\353\246\254 \353\251\200\353\246\254\353\233\260\352\270\260.md" diff --git "a/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-6209] \354\240\234\354\236\220\353\246\254 \353\251\200\353\246\254\353\233\260\352\270\260.md" "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-6209] \354\240\234\354\236\220\353\246\254 \353\251\200\353\246\254\353\233\260\352\270\260.md" new file mode 100644 index 0000000..6a09d04 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-6209] \354\240\234\354\236\220\353\246\254 \353\251\200\353\246\254\353\233\260\352\270\260.md" @@ -0,0 +1,71 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int D, N, M; + static int[] A; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + D = nextInt(); + N = nextInt(); + M = nextInt(); + A = new int[N]; + for(int i=0;i>1; + while(s>1; + } + bw.write(m + "\n"); + + } + + static boolean check(int limit) { + int last = 0, cnt = 0; + for(int i=0;i= limit) { + last = A[i]; + cnt++; + } + return cnt >= M; + } + +} +``` From 0a442e53a2a017ffbca4a3a04d7869188f94ca81 Mon Sep 17 00:00:00 2001 From: oncsr Date: Sat, 7 Jun 2025 23:16:19 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[BOJ-2306]=20=EC=9C=A0=EC=A0=84=EC=9E=90.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...] \354\234\240\354\240\204\354\236\220.md" | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 "\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2306] \354\234\240\354\240\204\354\236\220.md" diff --git "a/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2306] \354\234\240\354\240\204\354\236\220.md" "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2306] \354\234\240\354\240\204\354\236\220.md" new file mode 100644 index 0000000..f3c2b28 --- /dev/null +++ "b/\352\266\214\355\230\201\354\244\200_20\354\243\274\354\260\250/[BOJ-2306] \354\234\240\354\240\204\354\236\220.md" @@ -0,0 +1,83 @@ +```java +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController(){ + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + void nextLine() throws Exception { + st = new StringTokenizer(br.readLine()); + } + + String nextToken() throws Exception { + while(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + long nextLong() throws Exception { return Long.parseLong(nextToken()); } + double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static char[] A; + static int[][] dp; + static int N; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + A = ("?" + io.nextToken()).toCharArray(); + N = A.length-1; + dp = new int[N+1][N+1]; + + } + + static void solve() throws Exception { + + for(int k=1;k