题解 | #字符串加密#
字符串加密
http://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
按题意模拟即可
# include <bits/stdc++.h>
using namespace std;
int main() {
string k, s;
cin >> k >> s;
vector<char> alphabet;
unordered_set<char> seen;
for (auto& ch: k) {
if (!seen.count(ch)) {
seen.insert(ch);
alphabet.push_back(ch);
}
}
int n = alphabet.size();
for (char c = 'a'; c <= 'z'; c++) {
if (n < 26 && !seen.count(c)) {
alphabet.push_back(c);
}
}
string ans = "";
for (auto& ch: s) ans += alphabet[ch-'a'];
cout << ans;
return 0;
}