Skip to content

Commit

Permalink
Merge pull request #21 from AlgoLeadMe/6-YIM2UL2ET
Browse files Browse the repository at this point in the history
6-YIM2UL2ET
  • Loading branch information
YIM2UL2ET authored Mar 4, 2024
2 parents 4d7cb06 + 0709c31 commit 27d5b9f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
---
36 changes: 36 additions & 0 deletions YIM2UL2ET/μ •λ ¬/6μ°¨μ‹œ - BOJ 1599.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <algorithm>

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;
}

0 comments on commit 27d5b9f

Please sign in to comment.