From 8f3847de8b45ba87f747dd1fd67a77feb5860f1c Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 17:55:30 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[20250206]=20BOJ=20/=20G3=20/=20=EB=94=94?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=20=ED=8A=B8=EB=A6=AC=20/=20=EC=84=A4?= =?UTF-8?q?=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/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" diff --git "a/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" "b/Seol-JY/202502/05 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/05 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 95e8f07ff09c151c3f810fabb400c84c0edadaa0 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 17:56:30 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Delete=20Seol-JY/202502/05=20BOJ=20G3=20?= =?UTF-8?q?=EB=94=94=EC=8A=A4=ED=81=AC=20=ED=8A=B8=EB=A6=AC.md?= 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 deletions(-) delete mode 100644 "Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" diff --git "a/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" "b/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" deleted file mode 100644 index 0c74c71c..00000000 --- "a/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" +++ /dev/null @@ -1,108 +0,0 @@ -```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 b8437519dbd917e5963c03c9dbcf3ddcbd521a23 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Feb 2025 17:57:48 +0900 Subject: [PATCH 3/3] =?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" | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 "Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" diff --git "a/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" "b/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" new file mode 100644 index 00000000..ad04fc7e --- /dev/null +++ "b/Seol-JY/202502/05 BOJ G3 \353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.md" @@ -0,0 +1,106 @@ +```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()); + } + } +} +```