b站视频
https://www.bilibili.com/video/BV1GZ4y1d7XH/
#include <bits/stdc++.h>
using namespace std;
int main() {
int s, t, w;
cin >> s >> t >> w;
char lastLetter = 'a' + t - 1;
string a;
cin >> a;
int pos = -1;
for (int i = 1; i <= 5; i ++) {
for (int j = w - 1; j >= 0; j --) {
if (a[j] + w - 1 - j < lastLetter) {
pos = j;
break;
}
}
if (pos == -1) {
return 0;
}
a[pos] ++;
for (int j = pos + 1; j < w; j ++) {
a[j] = a[j - 1] + 1;
}
cout << a << endl;
}
return 0;
}