CF1927B 题解
思路
这就是一个贪心题,若
代码
# include <bits/stdc++.h>
using namespace std;
int t, n, x;
queue <char> q[200005];
char tot, ans;
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> t;
while (t --) {
cin >> n;
tot = 'a'; //tot 是指当前第一个没出现过的字符
for (int i = 0; i < n; ++ i) {
while (! q[i].empty ()) //多组数据要清空
q[i].pop ();
cin >> x;
if (x)
cout << (ans = q[x - 1].front ()), q[x - 1].pop (), q[x].push (ans); //在 q[x-1] 里找元素
else
cout << (ans = tot), q[0].push (tot), ++ tot;
}
cout << '\n';
}
return 0;
}