-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from AlgoLeadMe/6-YIM2UL2ET
6-YIM2UL2ET
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |