diff --git a/YIM2UL2ET/README.md b/YIM2UL2ET/README.md index dd45cb3..a76b85f 100644 --- a/YIM2UL2ET/README.md +++ b/YIM2UL2ET/README.md @@ -6,5 +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.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..ec0d7bb --- /dev/null +++ "b/YIM2UL2ET/\354\236\254\352\267\200/7\354\260\250\354\213\234 -BOJ 2705.cpp" @@ -0,0 +1,23 @@ +#include + +int ary[1000] = {0}; + +int solve(int n) +{ + 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; + std::cout << solve(input) << std::endl; + } + return 0; +} \ No newline at end of file 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..3b02e86 --- /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 translation(std::string min_str) +{ + 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 alpha_str; +} + +bool compare(std::string str1, std::string str2) +{ + return translation(str1) < translation(str2); +} + +int main(void) +{ + int n; + std::cin >> n; + + std::string min_str[n]; + for (int i = 0; i < n; i++) std::cin >> min_str[i]; + + std::sort(min_str, min_str+n, compare); + + for (int i = 0; i < n; i++) std::cout << min_str[i] << std::endl; + return 0; +} \ No newline at end of file