diff --git a/README.md b/README.md index 431b8e8..e6981a6 100644 --- a/README.md +++ b/README.md @@ -576,9 +576,48 @@ 2022년 여름방학 알고리즘 스터디 -| | Dltmd202 | SongSiWoon | ahnjongin | yj010306 | sa11k | -|----------------------------------------------------|:----------:|:------------:|:-----------:|:----------:|:-------:| -| [체스판 다시 칠하기](https://www.acmicpc.net/problem/1018) | ✅ | | | | ✅ | -| [직사각형에서 탈출](https://www.acmicpc.net/problem/1085) | | | | | ✅ | +| | Dltmd202 | SongSiWoon | ahnjongin | yj010306 | sa11k | +|------------------------------------------------------|:--------:|:----------:|:---------:|:--------:|:-----:| +| [직사각형에서 탈출](https://www.acmicpc.net/problem/1085) | ✅ | | | | ✅ | +| [체스판 다시 칠하기](https://www.acmicpc.net/problem/1018) | | | | | ✅ | +| [단어 정렬](https://www.acmicpc.net/problem/1181) | | | | | | +| [팰린드롬수](https://www.acmicpc.net/problem/1259) | | | | | | +| [영화감독 숌](https://www.acmicpc.net/problem/1436) | | | | | | +| [랜선 자르기](https://www.acmicpc.net/problem/1654) | | | | | | +| [스택 수열](https://www.acmicpc.net/problem/1874) | | | | | | +| [수 찾기](https://www.acmicpc.net/problem/1920) | | | | | | +| [소수 구하기](https://www.acmicpc.net/problem/1929) | | | | | | +| [프린터 큐](https://www.acmicpc.net/problem/1966) | | | | | | +| [소수 찾기](https://www.acmicpc.net/problem/1978) | | | | | | +| [통계학](https://www.acmicpc.net/problem/2108) | | | | | | +| [카드2](https://www.acmicpc.net/problem/2164) | | | | | | +| [분해합](https://www.acmicpc.net/problem/2231) | | | | | | +| [벌집](https://www.acmicpc.net/problem/2292) | | | | | | +| [최대공약수와 최소공배수](https://www.acmicpc.net/problem/2609) | | | | | | +| [수 정렬하기 2](https://www.acmicpc.net/problem/2751) | | | | | | +| [부녀회장이 될테야](https://www.acmicpc.net/problem/2775) | | | | | | +| [블랙잭](https://www.acmicpc.net/problem/2798) | | | | | | +| [나무 자르기](https://www.acmicpc.net/problem/2805) | | | | | | +| [설탕 배달](https://www.acmicpc.net/problem/2839) | | | | | | +| [달팽이는 올라가고 싶다](https://www.acmicpc.net/problem/2869) | | | | | | +| [직각삼각형](https://www.acmicpc.net/problem/4153) | | | | | | +| [균형잡힌 세상](https://www.acmicpc.net/problem/4949) | | | | | | +| [덩치](https://www.acmicpc.net/problem/7568) | | | | | | +| [괄호](https://www.acmicpc.net/problem/9012) | | | | | | +| [ACM 호텔](https://www.acmicpc.net/problem/10250) | | | | | | +| [제로](https://www.acmicpc.net/problem/10773) | | | | | | +| [나이순 정렬](https://www.acmicpc.net/problem/10814) | | | | | | +| [숫자 카드 2](https://www.acmicpc.net/problem/10816) | | | | | | +| [스택](https://www.acmicpc.net/problem/10828) | | | | | | +| [큐](https://www.acmicpc.net/problem/10845) | | | | | | +| [덱](https://www.acmicpc.net/problem/10866) | | | | | | +| [수 정렬하기 3](https://www.acmicpc.net/problem/10989) | | | | | | +| [이항 계수 1](https://www.acmicpc.net/problem/11050) | | | | | | +| [좌표 정렬하기](https://www.acmicpc.net/problem/11650) | | | | | | +| [좌표 정렬하기 2](https://www.acmicpc.net/problem/11651) | | | | | | +| [요세푸스 문제 0](https://www.acmicpc.net/problem/11866) | | | | | | +| [Hashing](https://www.acmicpc.net/problem/15829) | | | | | | +| [마인크래프트](https://www.acmicpc.net/problem/18111) | | | | | | + diff --git a/src/BaekJoon/Dltmd202/1018/Main.java b/src/BaekJoon/Dltmd202/1018/Main.java new file mode 100644 index 0000000..6906bf0 --- /dev/null +++ b/src/BaekJoon/Dltmd202/1018/Main.java @@ -0,0 +1,46 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + StringTokenizer st = new StringTokenizer(br.readLine()); + + int n = Integer.parseInt(st.nextToken()); + int m = Integer.parseInt(st.nextToken()); + char[][] map = new char[n][m]; + char[] checker = {'W', 'B'}; + + for (int i = 0; i < n; i++) { + map[i] = br.readLine().toCharArray(); + } + + int res = Integer.MAX_VALUE; + for (int i = 0; i <= n - 8; i++) { + for (int j = 0; j <= m - 8; j++) { + res = Math.min(res, check(n, m, map, checker, 0, i, j)); + res = Math.min(res, check(n, m, map, checker, 1, i, j)); + } + } + System.out.println(res); + } + + private static int check(int n, int m, char[][] map, char[] checker, int grad, int sy, int sx) { + int modified = 0; + int turn = grad; + for (int i = sy; i < sy + 8; i++) { + for (int j = sx; j < sx + 8; j++) { + if (checker[turn % 2] != map[i][j]) { + modified++; + } + turn++; + } + turn++; + } + return modified; + } +} diff --git a/src/BaekJoon/Dltmd202/1085/Main.java b/src/BaekJoon/Dltmd202/1085/Main.java new file mode 100644 index 0000000..b918449 --- /dev/null +++ b/src/BaekJoon/Dltmd202/1085/Main.java @@ -0,0 +1,47 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + static class Coordinate{ + int x; + int y; + + public Coordinate(int x, int y) { + this.y = y; + this.x = x; + } + + private int minDifference(Coordinate c){ + return Math.min( + Math.abs(this.x - c.x), + Math.abs(this.y - c.y) + ); + } + } + + public static void main(String[] args) throws IOException { + StringTokenizer st = new StringTokenizer(br.readLine()); + Coordinate hansu = new Coordinate( + Integer.parseInt(st.nextToken()), + Integer.parseInt(st.nextToken()) + ); + + Coordinate lowerLeft = new Coordinate(0 ,0); + + Coordinate upperRight = new Coordinate( + Integer.parseInt(st.nextToken()), + Integer.parseInt(st.nextToken()) + ); + + int min = Integer.MAX_VALUE; + + min = Math.min(min, hansu.minDifference(lowerLeft)); + min = Math.min(min, hansu.minDifference(upperRight)); + + System.out.println(min); + } +} diff --git a/src/BaekJoon/Dltmd202/1181/Main.java b/src/BaekJoon/Dltmd202/1181/Main.java new file mode 100644 index 0000000..13d5258 --- /dev/null +++ b/src/BaekJoon/Dltmd202/1181/Main.java @@ -0,0 +1,48 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + int n = Integer.parseInt(br.readLine()); + String[] strs = new String[n]; + Set visited = new HashSet<>(); + + for (int i = 0; i < n; i++) { + strs[i] = br.readLine(); + } + + Arrays.sort(strs, + new Comparator() { + @Override + public int compare(String o1, String o2) { + if(o1.length() == o2.length()) + return o1.compareTo(o2); + else { + return o1.length() - o2.length(); + } + } + }); + + System.out.println( + Arrays.stream(strs) + .filter(s -> { + if(!visited.contains(s)){ + visited.add(s); + return true; + } + return false; + }) + .map(String::valueOf) + .collect(Collectors.joining("\n")) + ); + } +} diff --git a/src/BaekJoon/Dltmd202/1259/Main.java b/src/BaekJoon/Dltmd202/1259/Main.java new file mode 100644 index 0000000..d252ed4 --- /dev/null +++ b/src/BaekJoon/Dltmd202/1259/Main.java @@ -0,0 +1,27 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + while (true){ + int n = Integer.parseInt(br.readLine()); + if(n == 0) break; + char[] ary = String.valueOf(n).toCharArray(); + sb.append(getAnswer(ary)).append("\n"); + } + System.out.println(sb.toString()); + } + + private static String getAnswer(char[] ary) { + int left = 0, right = ary.length - 1; + + while (left < right){ + if(ary[left++] != ary[right--]) return "no"; + } + return "yes"; + } +} diff --git a/src/BaekJoon/Dltmd202/1436/Main.java b/src/BaekJoon/Dltmd202/1436/Main.java new file mode 100644 index 0000000..021f455 --- /dev/null +++ b/src/BaekJoon/Dltmd202/1436/Main.java @@ -0,0 +1,31 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + int turn = Integer.parseInt(br.readLine()); + long n = 666; + + int cnt = 0; + while (true){ + char[] numArray = String.valueOf(n).toCharArray(); + if(isValid(numArray)) cnt++; + if(cnt == turn) break; + n++; + } + System.out.println(n); + } + + private static boolean isValid(char[] numArray) { + for (int i = 0; i <= numArray.length - 3; i++) { + if(numArray[i] == '6' && numArray[i + 1] == '6' && numArray[i + 2] == '6'){ + return true; + } + } + return false; + } +}