From 6ae28fe79a3f89ac1eb90afe2a966f1459a286ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Wed, 28 Feb 2024 02:36:08 +0900 Subject: [PATCH 1/6] =?UTF-8?q?6=EC=B0=A8=EC=8B=9C=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YIM2UL2ET/README.md | 1 + .../6\354\260\250\354\213\234 - BOJ 1599.cpp" | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 "YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index dd45cb3..71c5f9a 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -7,4 +7,5 @@ | 3차시 | 2024.02.18 | 스택 | [BOJ 2504](https://www.acmicpc.net/problem/2504) | [BOJ 2504 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/9) | | 4차시 | 2024.02.21 | 덱 | [BOJ 1021](https://www.acmicpc.net/problem/1021) | [BOJ 1021 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/12) | | 5차시 | 2024.02.21 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | +| 5차시 | 2024.02.21 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | --- diff --git "a/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" "b/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" new file mode 100644 index 0000000..0950671 --- /dev/null +++ "b/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" @@ -0,0 +1,36 @@ +#include +#include + +std::string change_string(std::string str) +{ + int delay = 0; + std::string new_str = str; + for (int i = 0; i < str.size(); i++) { + if (str[i] == 'k') new_str[i-delay] = 'c'; + else if (str[i] > 'n') new_str[i-delay]++; + else if (str[i] == 'n' && i+1 < str.size() && str[i+1] == 'g') { + new_str.erase(new_str.begin() + (i++) - delay); + new_str[i - (++delay)] = 'o'; + } + } + return new_str; +} + +bool compare(std::string str1, std::string str2) +{ + return change_string(str1) < change_string(str2); +} + +int main(void) +{ + int n; + std::cin >> n; + + std::string str[n]; + for (int i = 0; i < n; i++) std::cin >> str[i]; + + std::sort(str, str+n, compare); + + for (int i = 0; i < n; i++) std::cout << str[i] << std::endl; + return 0; +} \ No newline at end of file From 0709c31ce2f352c07b944aa6b301e92085377240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:33:44 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../6\354\260\250\354\213\234 - BOJ 1599.cpp" | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git "a/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" "b/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" index 0950671..3b02e86 100644 --- "a/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" +++ "b/YIM2UL2ET/\354\240\225\353\240\254/6\354\260\250\354\213\234 - BOJ 1599.cpp" @@ -1,24 +1,24 @@ #include #include -std::string change_string(std::string str) +std::string translation(std::string min_str) { - int delay = 0; - std::string new_str = str; - for (int i = 0; i < str.size(); i++) { - if (str[i] == 'k') new_str[i-delay] = 'c'; - else if (str[i] > 'n') new_str[i-delay]++; - else if (str[i] == 'n' && i+1 < str.size() && str[i+1] == 'g') { - new_str.erase(new_str.begin() + (i++) - delay); - new_str[i - (++delay)] = 'o'; + int s_diff = 0; + std::string alpha_str = min_str; + for (int i = 0; i < min_str.size(); i++) { + if (min_str[i] == 'k') alpha_str[i-s_diff] = 'c'; + else if (min_str[i] > 'n') alpha_str[i-s_diff]++; + else if (min_str[i] == 'n' && i+1 < min_str.size() && min_str[i+1] == 'g') { + alpha_str.erase(alpha_str.begin() + (i++) - s_diff); + alpha_str[i - (++s_diff)] = 'o'; } } - return new_str; + return alpha_str; } bool compare(std::string str1, std::string str2) { - return change_string(str1) < change_string(str2); + return translation(str1) < translation(str2); } int main(void) @@ -26,11 +26,11 @@ int main(void) int n; std::cin >> n; - std::string str[n]; - for (int i = 0; i < n; i++) std::cin >> str[i]; + std::string min_str[n]; + for (int i = 0; i < n; i++) std::cin >> min_str[i]; - std::sort(str, str+n, compare); + std::sort(min_str, min_str+n, compare); - for (int i = 0; i < n; i++) std::cout << str[i] << std::endl; + for (int i = 0; i < n; i++) std::cout << min_str[i] << std::endl; return 0; } \ No newline at end of file From 3105f5ca3396cf456afc8a87baf8a48e5b63563e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Fri, 1 Mar 2024 23:48:03 +0900 Subject: [PATCH 3/6] =?UTF-8?q?7=EC=B0=A8=EC=8B=9C=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YIM2UL2ET/README.md | 5 +++-- .../7\354\260\250\354\213\234 -BOJ 2705.cpp" | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index 71c5f9a..a76b85f 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -6,6 +6,7 @@ | 2차시 | 2024.02.15 | 그리디 | [BOJ 1263](https://www.acmicpc.net/problem/1263) | [BOJ 1449 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/7) | | 3차시 | 2024.02.18 | 스택 | [BOJ 2504](https://www.acmicpc.net/problem/2504) | [BOJ 2504 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/9) | | 4차시 | 2024.02.21 | 덱 | [BOJ 1021](https://www.acmicpc.net/problem/1021) | [BOJ 1021 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/12) | -| 5차시 | 2024.02.21 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | -| 5차시 | 2024.02.21 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | +| 5차시 | 2024.02.24 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | +| 6차시 | 2024.02.27 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | +| 7차시 | 2024.03.01 | 재귀 | [BOJ 2705](https://www.acmicpc.net/problem/2705) | [BOJ 2705 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/23) | --- diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" new file mode 100644 index 0000000..f44c84c --- /dev/null +++ "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" @@ -0,0 +1,22 @@ +#include + +int ary[1000] = {0}; + +int solve(int n) +{ + if (n == 1) return 1; + else if (ary[n-1] != 0) return ary[n-1]; + for (int i = 0; n-i*2 > 1; i++) ary[n-1] += solve(i+1); + return ++ary[n-1]; +} + +int main(void) +{ + int n, input; + std::cin >> n; + for (int i = 0; i < n; i++) { + std::cin >> input; + std::cout << solve(input) << std::endl; + } + return 0; +} \ No newline at end of file From 5f4b652426dfa4527bf59f023738320f81dedbc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Sat, 2 Mar 2024 03:15:02 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../7\354\260\250\354\213\234 -BOJ 2705.cpp" | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" index f44c84c..ec0d7bb 100644 --- "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" +++ "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" @@ -4,15 +4,16 @@ int ary[1000] = {0}; int solve(int n) { - if (n == 1) return 1; - else if (ary[n-1] != 0) return ary[n-1]; - for (int i = 0; n-i*2 > 1; i++) ary[n-1] += solve(i+1); + if (ary[n-1] != 0) return ary[n-1]; + for (int i = 0; n-i*2 > 1;) ary[n-1] += solve(++i); return ++ary[n-1]; } int main(void) { int n, input; + ary[0] = 1; + std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> input; From 9dfb20b5b1e7179966a46e856b1f938c288d3ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:20:46 +0900 Subject: [PATCH 5/6] =?UTF-8?q?8=EC=B0=A8=EC=8B=9C=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YIM2UL2ET/README.md | 1 + .../7\354\260\250\354\213\234 - BOJ 2705.cpp" | 0 ...8\354\260\250\354\213\234 - BOJ 10994.cpp" | 42 +++++++++++++++++++ 3 files changed, 43 insertions(+) rename "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" => "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 - BOJ 2705.cpp" (100%) create mode 100644 "YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index a76b85f..eaef663 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -9,4 +9,5 @@ | 5차시 | 2024.02.24 | 큐 | [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) | | 6차시 | 2024.02.27 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) | | 7차시 | 2024.03.01 | 재귀 | [BOJ 2705](https://www.acmicpc.net/problem/2705) | [BOJ 2705 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/23) | +| 8차시 | 2024.03.01 | 재귀 | [BOJ 10994](https://www.acmicpc.net/problem/10994) | [BOJ 10994 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/27) | --- diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 - BOJ 2705.cpp" similarity index 100% rename from "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" rename to "YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 - BOJ 2705.cpp" diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" new file mode 100644 index 0000000..369314c --- /dev/null +++ "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" @@ -0,0 +1,42 @@ +#include + +void func1(int n, int m) +{ + for (int i = 0; i < m; i++) std::cout << "* "; + for (int i = 0; i < 4*(n-1)+1; i++) std::cout << "*"; + for (int i = 0; i < m; i++) std::cout << " *"; + std::cout << "\n"; +} + +void func2(int n, int m) +{ + for (int i = 0; i < m; i++) std::cout << "* "; + std::cout << "*"; + for (int i = 0; i < 4*(n-1)-1; i++) std::cout << " "; + std::cout << "*"; + for (int i = 0; i < m; i++) std::cout << " *"; + std::cout << "\n"; +} + +void star(int n, int m) +{ + if (n == 1) { + for (int i = 0; i < (n+m)*2-1; i++) std::cout << "* "; + std::cout << "\n"; + } + else { + func1(n, m); + func2(n, m); + star(n-1, m+1); + func2(n, m); + func1(n, m); + } +} + +int main(void) +{ + int n; + std::cin >> n; + star(n, 0); + return 0; +} \ No newline at end of file From 59c0e154a199d3f6656bee798ee7ee038724b8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=8A=B9=ED=98=B8?= <132066506+YIM2UL2ET@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:37:40 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=ED=95=A8=EC=88=98=20=EB=B0=8F=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...8\354\260\250\354\213\234 - BOJ 10994.cpp" | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git "a/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" index 369314c..8728e2e 100644 --- "a/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" +++ "b/YIM2UL2ET/\354\236\254\352\267\200/8\354\260\250\354\213\234 - BOJ 10994.cpp" @@ -1,35 +1,35 @@ #include -void func1(int n, int m) +void cover1(int n, int level) { - for (int i = 0; i < m; i++) std::cout << "* "; - for (int i = 0; i < 4*(n-1)+1; i++) std::cout << "*"; - for (int i = 0; i < m; i++) std::cout << " *"; + for (int i = 0; i < level; i++) std::cout << "* "; + for (int i = 0; i < 4*(n-level)-3; i++) std::cout << "*"; + for (int i = 0; i < level; i++) std::cout << " *"; std::cout << "\n"; } -void func2(int n, int m) +void cover2(int n, int level) { - for (int i = 0; i < m; i++) std::cout << "* "; + for (int i = 0; i < level; i++) std::cout << "* "; std::cout << "*"; - for (int i = 0; i < 4*(n-1)-1; i++) std::cout << " "; + for (int i = 0; i < 4*(n-level)-5; i++) std::cout << " "; std::cout << "*"; - for (int i = 0; i < m; i++) std::cout << " *"; + for (int i = 0; i < level; i++) std::cout << " *"; std::cout << "\n"; } -void star(int n, int m) +void star(int n, int level) { - if (n == 1) { - for (int i = 0; i < (n+m)*2-1; i++) std::cout << "* "; - std::cout << "\n"; + if (n == level+1) { + for (int i = 0; i < n*2-2; i++) std::cout << "* "; + std::cout << "*\n"; } else { - func1(n, m); - func2(n, m); - star(n-1, m+1); - func2(n, m); - func1(n, m); + cover1(n, level); + cover2(n, level); + star(n, level+1); + cover2(n, level); + cover1(n, level); } }