#include <iostream> #include <string> #include <bitset> #include <algorithm> #include <cctype> #include <vector> using namespace std; const char hex_table[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; char adjust(const char& c) { int n; if(isdigit(c)) { //c是'0'-'9' n = c - '0'; } else if(islower(c)) { //c是小写字母 n = c - 'a' + 10; } else if(isupper(c)) { //c是大写字母 n = c - 'A' + 10; } if(n > 15) return c; //傻逼题目 说好的只输入a-f 测试用例还输入别的 bitset<4> b(n); string str = b.to_string(); reverse(str.begin(), str.end()); bitset<4> newb(str); unsigned long ul = newb.to_ulong(); return hex_table[ul]; } int main() { string s, t, u; cin >> s >> t; u = s + t; // 分离奇偶索引的元素 vector<char> evenChars; // 偶数索引 vector<char> oddChars; // 奇数索引 for (size_t i = 0; i < u.size(); ++i) { if (i % 2 == 0) { evenChars.push_back(u[i]); } else { oddChars.push_back(u[i]); } } // 分别排序 sort(evenChars.begin(), evenChars.end()); sort(oddChars.begin(), oddChars.end()); // 合并结果 size_t evenIdx = 0, oddIdx = 0; for (size_t i = 0; i < u.size(); ++i) { if (i % 2 == 0) { u[i] = evenChars[evenIdx++]; } else { u[i] = oddChars[oddIdx++]; } } string ans; for(const char& c: u) { ans += adjust(c); } cout << ans << endl; return 0; }