From b0f8c6a65e8dbf87f361e545ad3cf2a86e5dd65b Mon Sep 17 00:00:00 2001 From: seomiii Date: Mon, 23 Oct 2023 20:38:39 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=20[solved]=2010=EC=9B=94=203=EC=A3=BC?= =?UTF-8?q?=EC=B0=A8=20=EB=AA=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KimMiSeo/BOJ/BOJ17297_MessiGimossi.java | 78 +++++++++++++++++++ ...\354\204\234\353\271\204\354\212\244.java" | 53 +++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 KimMiSeo/BOJ/BOJ17297_MessiGimossi.java create mode 100644 "KimMiSeo/BOJ/BOJ2533_\354\202\254\355\232\214\353\247\235\354\204\234\353\271\204\354\212\244.java" diff --git a/KimMiSeo/BOJ/BOJ17297_MessiGimossi.java b/KimMiSeo/BOJ/BOJ17297_MessiGimossi.java new file mode 100644 index 00000000..f4c9112b --- /dev/null +++ b/KimMiSeo/BOJ/BOJ17297_MessiGimossi.java @@ -0,0 +1,78 @@ +import java.io.*; +import java.sql.SQLOutput; +import java.util.*; +public class BOJ17297_MessiGimossi { + static int M, messiLen,index,cnt; + static String result,temp; + static ArrayList list = new ArrayList<>(); + public static void main(String[] args) throws Exception { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + M = Integer.parseInt(br.readLine()) - 1; // 인덱스 + messiLen = 0; + temp = "Messi Gimossi"; + list.add(5); + list.add(13); + + index = 0; + + if (M <= 13){ + result = String.valueOf(temp.charAt(M)); + if (result.equals(" ")){ + result = "Messi Messi Gimossi"; + } + } else { + getMessiLen(); +// System.out.println(list); + messi(list.size()-1); + } + + System.out.println(result); + } + + private static void messi(int index){ + // 0 ~ memo[0]-1 + // memo[0] + // memo[0]+1 ~ memo[0]+memo[1] + //System.out.println(Arrays.toString(memo)+" dddddd"+ messiLen); + + messiLen = list.get(index); +// System.out.println(messiLen+" messilen "+ index+ " "+M); + + if (messiLen <= 13){ +// System.out.println(M); + result = String.valueOf(temp.charAt(M)); + if (result.equals(" ")){ + result = "Messi Messi Gimossi"; + } + return; + } + + int left = list.get(index - 1); + int right = list.get(index - 2); +// System.out.println(left +" left "+ right + " right "+ messiLen); + + if (M == left){ // 가운데 + result = "Messi Messi Gimossi"; + return; + } + + if ( M <= left - 1 ){ // 왼쪽이면 + messi(index - 1); + } +// System.out.println(left+1 +" "+ (left+right)+" " + M); + if (M>= left + 1 && M <= left+right ){ // 오른쪽이면 + M -= ( left + 1 ); +// System.out.println(M); + messi(index - 2); + } + } + + private static void getMessiLen(){ + while(list.get(list.size()-1) <= M){ + int first = list.get(list.size()-1); + int second = list.get(list.size()-2); + list.add(first + second + 1); + } + } +} diff --git "a/KimMiSeo/BOJ/BOJ2533_\354\202\254\355\232\214\353\247\235\354\204\234\353\271\204\354\212\244.java" "b/KimMiSeo/BOJ/BOJ2533_\354\202\254\355\232\214\353\247\235\354\204\234\353\271\204\354\212\244.java" new file mode 100644 index 00000000..01e53e0e --- /dev/null +++ "b/KimMiSeo/BOJ/BOJ2533_\354\202\254\355\232\214\353\247\235\354\204\234\353\271\204\354\212\244.java" @@ -0,0 +1,53 @@ +import java.io.*; +import java.util.*; + +/** + * 얼리 아답터가 아닌 사람들은 자신의 모든 친구들이 얼리 아답터일 때만 이 아이디어를 받아들인다. + * 라는 구문에서 dp를 떠올릴 수 있는 훈련이 필요하다고 생각됩니다! + */ + +public class BOJ2533_사회망서비스 { + static int N; + static int[][] dp; + static boolean[] visited; + static List list = new ArrayList<>(); + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + + for (int i=0; i()); + } + + for (int i=0; i Date: Mon, 23 Oct 2023 20:39:04 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=20[solved]=20BOJ12919=5FA=EC=99=80B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "KimMiSeo/BOJ/BOJ12919_A\354\231\200B2.java" | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "KimMiSeo/BOJ/BOJ12919_A\354\231\200B2.java" diff --git "a/KimMiSeo/BOJ/BOJ12919_A\354\231\200B2.java" "b/KimMiSeo/BOJ/BOJ12919_A\354\231\200B2.java" new file mode 100644 index 00000000..6154879c --- /dev/null +++ "b/KimMiSeo/BOJ/BOJ12919_A\354\231\200B2.java" @@ -0,0 +1,45 @@ +import java.io.*; +import java.util.*; +public class BOJ12919_A와B2 { + static String S,T; + static boolean result; + static StringBuilder sb; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + sb = new StringBuilder(); + S = br.readLine(); + T = br.readLine(); + result = false; + solve(T); + if (result){ + System.out.println(1); + }else{ + System.out.println(0); + } + } + + private static void solve(String t){ + // System.out.println(t); + if (t.length() == S.length()){ + if (t.equals(S)){ + result=true; + } + return; + } + + int len = t.length(); + // A를 붙였다면 + if ( t.charAt(len-1) == 'A'){ + solve(t.substring(0, len-1)); + } + + // B를 붙였다면 + if ( t.charAt(0) == 'B' ){ + sb.append(t); + String temp = ""; + temp = sb.reverse().toString(); + temp = temp.substring(0,len-1); + solve(temp); + } + } +} From 27845aec4ad3ad5a108e6f1a1e7946033cbb40ae Mon Sep 17 00:00:00 2001 From: seomiii Date: Mon, 23 Oct 2023 20:39:14 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=20[solved]=20BOJ10159=5F=EC=A0=80=EC=9A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ10159_\354\240\200\354\232\270.java" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "KimMiSeo/BOJ/BOJ10159_\354\240\200\354\232\270.java" diff --git "a/KimMiSeo/BOJ/BOJ10159_\354\240\200\354\232\270.java" "b/KimMiSeo/BOJ/BOJ10159_\354\240\200\354\232\270.java" new file mode 100644 index 00000000..faaed400 --- /dev/null +++ "b/KimMiSeo/BOJ/BOJ10159_\354\240\200\354\232\270.java" @@ -0,0 +1,63 @@ +import java.io.*; +import java.util.*; + +// 무게가 서로 다른 n개의 물건 , 1~n +// 각 물건에 대해서 그 물건과의 비교 결과를 알 수 없는 물건의 개수 + +// 5 <= 물건의 개수 n <= 100 +// 0<= 물건 쌍의 개수 m <= 2000 +public class BOJ10159_저울 { + // 큰 애들로 이어진 그래프, 작은 애들로 이어진 그래프 2개로 운영하기 + // visited 배열은 같은 그래프 사용하기 + // 이어진 개수를 구해서 최종 개수에서 빼주기!! + static ArrayList> biggerList, smallerList; + static boolean[] visited; + static int N,M; + static int cnt; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + M = Integer.parseInt(br.readLine()); + + biggerList = new ArrayList<>(); + smallerList = new ArrayList<>(); + + for (int i=0; i<=N; i++){ + biggerList.add(new ArrayList<>()); + smallerList.add(new ArrayList<>()); + } + + for (int i=0; i> list){ + ArrayList links = list.get(cur); + int len = links.size(); + + for (int i=0; i