题目:
思路分析:
代码实现:
/*
*@Author: GuoJinlong
*@Language: C++
*/
//#include <bits/stdc++.h>
/*
* __----~~~~~~~~~~~------___
* . . ~~//====...... __--~ ~~
* -. \_|// |||\\ ~~~~~~::::... /~
* ___-==_ _-~o~ \/ ||| \\ _/~~-
* __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
* _-~~ .=~ | \\-_ '-~7 /- / || \ /
* .~ .~ | \\ -_ / /- / || \ /
* / ____ / | \\ ~-_/ /|- _/ .|| \ /
* |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
* ' ~-| /| |-~\~~ __--~~
* |-~~-_/ | | ~\_ _-~ /\
* / \ \__ \/~ \__
* _--~ _/ | .-~~____--~-/ ~~==.
* ((->/~ '.|||' -_| ~~-/ , . _||
* -_ ~\ ~~---l__i__i__i--~~_/
* _-~-__ ~) \--______________--~~
* //.-~~~-~_--~- |-------~~~~~~~~
* //.-~~~--\
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 神兽保佑 永无BUG
*/
map<char, char> mp;
set<char> ss;
int main()
{
int n;
cin>>n;
string str;
cin>>str;
string temp = "";
set<string> s;
for (int i = 0; i < str.size(); i ++)
{
temp += str[i];
mp.clear();
ss.clear();
for (int j = temp.size() - 1; j >= 0; j --)
{
if (!ss.count(temp[j])) mp[temp[j]] = ('a' + ss.size());
ss.insert(temp[j]);
}
string temp2 = "";
for (int j = 0; j < temp.size(); j ++)
{
temp2 += mp[temp[j]];
}
s.insert(temp2);
}
string res = "";
for (auto it = s.begin(); it != s.end(); it ++)
{
res = *it;
}
cout << res << endl;
return 0;
}