场掉了かふ
省流:人均题。
题面
给定一个长度为
现在可以将字符串中的每个字符
思路
字典序优先考虑相同位置的字符大小,所以两个字符
考虑以下情况:
对于
所以越前的字符优先级越高;考场思路是以每两个字符
对于一个长度为
按照进制转换的基础思想,用一个循环依次求出
关键代码形如:
for (int i = scnt; i; i --)
ot[i] = k % cnt[i], k /= cnt[i];
/*
scnt : 间隔数
ot[i] : 第 i 个间隔里应该填多少个字符 b
cnt[i] : 第 i 个间隔的进制是什么
*/
Tips:由于有
代码
CF Record.
#include <bits/stdc++.h>
#define break ({break;})
#define continue ({continue;})
#define return(x) ({return x;})
using namespace std;
typedef long long i64;
typedef double f16;
typedef pair <int, int> pii;
const int N = 2e3 + 10;
int n, m, cnt[N], ot[N], scnt;
string s;
i64 k;
void Solve ()
{
cin >> n >> m >> k >> s;
scnt = 0;
s = " " + s; int last = 0;
for (int i = 1; i <= n; i ++)
if (s[i] == 'a')
{
if (i == 1) last = 1, continue;
cnt[++ scnt] = i - 1 - last;
last = i;
}
cnt[++ scnt] = n - last;
for (int i = 1; i <= scnt; i ++)
cnt[i] = cnt[i] * m + 1;
k --;
for (int i = scnt; i; i --)
ot[i] = k % cnt[i], k /= cnt[i];
for (int i = 1; i <= scnt; i ++)
{
if (!(i == 1 && s[1] == '*')) cout << 'a';
while (ot[i] --) cout << 'b';
}
cout << '\n';
}
int main ()
{
int T; cin >> T;
while (T --) Solve ();
return 0;
}