inline T read(){ T sum = 0, fl = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1; for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0'; return sum * fl; }
template <typename T>
inlinevoidwrite(T x){ if (x < 0) { putchar('-'), write<T>(-x); return; } static T sta[35]; int top = 0; do { sta[top++] = x % 10, x /= 10; } while (x); while (top) putchar(sta[--top] + 48); }
intmain(){ IOS; cin >> s >> t; len = s.size(); for (int i = 0; i < len; ++i) if (s[i] != t[i]) { ++ret; if (s[i] < t[i]) b.push_front(i); /* 考场留下的写法,这一行是说要往大了改的放到 b 里,而且越后出现的越先改*/ else a.push_back(i); /*同上,反过来*/ /*这里之所以用 deque 主要是因为统一:下面可以统一使用 front 而不用在倒腾 front 和 back*/ } cout << ret << endl; while (!a.empty()) { /*先处理 a 改小*/ s[a.front()] = t[a.front()]; cout << s << endl; a.pop_front(); /*一定要pop*/ } while (!b.empty()) { /*再处理 b 改大*/ s[b.front()] = t[b.front()]; cout << s << endl; b.pop_front(); } return0; }