标签:_id print set end lin har color erase find
题目链接: http://exercise.acmcoder.com/online/online_judge_ques?ques_id=3369&konwledgeId=40
解题思路: 按照题意把每个出现的字符替换掉就可以了。
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 typedef long long LL; 5 const int MAXN=100005; 6 const LL MOD7 = 1e9+7; 7 8 set<char> unseen; 9 map<char,char> mp; 10 char s[MAXN]; 11 void solve() 12 { 13 unseen.clear(); 14 for (char ch=‘a‘;ch<=‘z‘;++ch) unseen.insert(ch); 15 mp.clear(); 16 char ch=‘a‘; 17 for (int i=0;s[i];++i) 18 { 19 auto it=unseen.find(s[i]); 20 if (it!=unseen.end()) 21 { 22 mp[*it]=ch++; 23 unseen.erase(it); 24 } 25 printf("%c",mp[s[i]]); 26 } 27 printf("\n"); 28 } 29 int main() 30 { 31 #ifndef ONLINE_JUDGE 32 freopen("test.txt","r",stdin); 33 #endif // ONLINE_JUDGE 34 scanf("%s",s); 35 solve(); 36 return 0; 37 }
标签:_id print set end lin har color erase find
原文地址:https://www.cnblogs.com/djingjing/p/8977949.html