From 0ca5d096e84562d201394133c15e4fabd91f3cec Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 16:35:53 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=20[20250206]=20BOJ=20/=20=EA=B3=A8?= =?UTF-8?q?=EB=93=9C5=20/=20=ED=9A=8C=EC=9E=A5=EB=BD=91=EA=B8=B0=20/=20?= =?UTF-8?q?=EC=84=A4=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...14\354\236\245\353\275\221\352\270\260.md" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" diff --git "a/Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" "b/Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" new file mode 100644 index 00000000..c1221a2e --- /dev/null +++ "b/Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" @@ -0,0 +1,71 @@ +```java +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +public class Main { + private static int N; + private static int[][] map; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + N = Integer.parseInt(br.readLine()); + map = new int[N][N]; + + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (i == j) map[i][j] = 0; + else map[i][j] = N + 1; // 최대값 초기화, 모두 거치면 무조건 친구라 했으므로 가능 + } + } + + while(true) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int x = Integer.parseInt(st.nextToken()); + int y = Integer.parseInt(st.nextToken()); + + if (x == -1 && y == -1) break; + map[y-1][x-1] = 1; + map[x-1][y-1] = 1; + } + + for (int i = 0; i < N; i++) { + for(int j = 0; j < N; j++) { + for (int k = j; k < N; k++) { + if (j == k) continue; + if (i == j || i == k) continue; + + int value = Math.min(map[j][k], map[j][i] + map[i][k]); + map[j][k] = value; + map[k][j] = value; + } + } + } + + int answer = N; + List answers = new ArrayList<>(); + + for (int i = 0; i < N; i++) { + int max = 0; + for (int j = 0; j < N; j++) { + max = Math.max(max, map[i][j]); + } + + if (answer > max) { + answers.clear(); + answer = max; + answers.add(i + 1); // 후보 추가 + } else if (answer == max) { + answers.add(i + 1); // 후보 추가 + } + } + + System.out.println(answer + " " + answers.size()); + for (int value: answers) { + System.out.print(value + " "); + } + } +} +``` From a8838091374cf69a06a8133ac5007d9227bb60ae Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 17:48:19 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[20250206]=20BOJ=20/=20=EA=B3=A8=EB=93=9C3?= =?UTF-8?q?=20/=20=EB=94=94=EC=8A=A4=ED=81=AC=20=ED=8A=B8=EB=A6=AC=20/=20?= =?UTF-8?q?=EC=84=A4=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\355\201\254 \355\212\270\353\246\254.md" | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 "Seol-JY/202502/04 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" diff --git "a/Seol-JY/202502/04 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" "b/Seol-JY/202502/04 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" new file mode 100644 index 00000000..0c74c71c --- /dev/null +++ "b/Seol-JY/202502/04 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" @@ -0,0 +1,108 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + private static int N; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + N = Integer.parseInt(br.readLine()); + + File root = File.from("root"); + for (int i = 0; i < N; i++) { + root.add(br.readLine().split("\\\\")); + } + + root.printTree(); + } + + private static class File implements Comparable { + private final String name; + private final Set files; + + private File(String name) { + this.name = name; + files = new TreeSet<>(); + } + + public static File from(String name) { + return new File(name); + } + + public void add(String[] names) { + add(names, 0); + } + + public void add(String[] names, int index) { + if (names.length == index) return; + String name = names[index]; + files.add(File.from(name)); + + for (File file : files) { + if (file.isSameName(name)) { + file.add(names, index + 1); + } + } + } + + public boolean isSameName(String name) { + return this.name.equals(name); + } + + public Set getFiles() { + return files; + } + + + public void printTree() { + printTree(0); + } + + public void printTree(int tabCount) { + if (files.isEmpty()) { + return; + } + + for (File file : files) { + for (int i = 0; i < tabCount; i++) { + System.out.print(" "); + } + System.out.println(file); + + file.printTree(tabCount + 1); + } + } + + @Override + public String toString() { + return name; + } + + // 파일이름에 대해서만 + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + File other = (File) obj; + return Objects.equals(name, other.name); + } + + @Override + public int compareTo(File o) { + return this.name.compareTo(o.toString()); + } + } +} + + +``` From 8f08b8cab4f5cf768bf61f14d4077aec162e43cd Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 17:50:09 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Rename=2006=20G5=20=EB=B3=84=EC=9E=90?= =?UTF-8?q?=EB=A6=AC=20=EC=B0=BE=EA=B8=B0.md=20to=2006=20BOJ=20G5=20?= =?UTF-8?q?=EB=B3=84=EC=9E=90=EB=A6=AC=20=EC=B0=BE=EA=B8=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "Seol-JY/202502/06 G5 \353\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" => "Seol-JY/202502/06 BOJ G5 \353\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" (100%) diff --git "a/Seol-JY/202502/06 G5 \353\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" "b/Seol-JY/202502/06 BOJ G5 \353\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" similarity index 100% rename from "Seol-JY/202502/06 G5 \353\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" rename to "Seol-JY/202502/06 BOJ G5 \353\263\204\354\236\220\353\246\254 \354\260\276\352\270\260.md" From e17b1ac0a37c519df1fea45941e59ee5ecb2a80c Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 17:50:43 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Delete=20Seol-JY/202502/06=20G5=20=ED=9A=8C?= =?UTF-8?q?=EC=9E=A5=EB=BD=91=EA=B8=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...14\354\236\245\353\275\221\352\270\260.md" | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 "Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" diff --git "a/Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" "b/Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" deleted file mode 100644 index c1221a2e..00000000 --- "a/Seol-JY/202502/06 G5 \355\232\214\354\236\245\353\275\221\352\270\260.md" +++ /dev/null @@ -1,71 +0,0 @@ -```java -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -public class Main { - private static int N; - private static int[][] map; - public static void main(String[] args) throws Exception { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - - N = Integer.parseInt(br.readLine()); - map = new int[N][N]; - - for (int i = 0; i < N; i++) { - for (int j = 0; j < N; j++) { - if (i == j) map[i][j] = 0; - else map[i][j] = N + 1; // 최대값 초기화, 모두 거치면 무조건 친구라 했으므로 가능 - } - } - - while(true) { - StringTokenizer st = new StringTokenizer(br.readLine()); - int x = Integer.parseInt(st.nextToken()); - int y = Integer.parseInt(st.nextToken()); - - if (x == -1 && y == -1) break; - map[y-1][x-1] = 1; - map[x-1][y-1] = 1; - } - - for (int i = 0; i < N; i++) { - for(int j = 0; j < N; j++) { - for (int k = j; k < N; k++) { - if (j == k) continue; - if (i == j || i == k) continue; - - int value = Math.min(map[j][k], map[j][i] + map[i][k]); - map[j][k] = value; - map[k][j] = value; - } - } - } - - int answer = N; - List answers = new ArrayList<>(); - - for (int i = 0; i < N; i++) { - int max = 0; - for (int j = 0; j < N; j++) { - max = Math.max(max, map[i][j]); - } - - if (answer > max) { - answers.clear(); - answer = max; - answers.add(i + 1); // 후보 추가 - } else if (answer == max) { - answers.add(i + 1); // 후보 추가 - } - } - - System.out.println(answer + " " + answers.size()); - for (int value: answers) { - System.out.print(value + " "); - } - } -} -```