理解好题意就OK了!
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <queue>
#include <stack>
using namespace std;
bool is(char a)
{
if((a>='0'&&a<='9')||(a>='a'&&a<='z')||(a>='A'&&a<='Z')) return 1;
else return 0;
}
string inct(string s)
{
int len = s.size();
s[len-1] ++;
for(int j = len-1;j >= 1;j --)
{
if(s[j] == ':') {s[j] = '0';s[j-1] ++;}
if(s[j] == '[') {s[j] = 'A';s[j-1] ++;}
if(s[j] == '{') {s[j] = 'a';s[j-1] ++;}
}
if(s[0] == ':') {s[0] = '0';s.insert(0,"1");}
if(s[0] == '[') {s[0] = 'A';s.insert(0,"A");}
if(s[0] == '{') {s[0] = 'a';s.insert(0,"a");}
return s;
}
int main()
{
int n,t,i;
string s,ss,ans;
cin>>n;
while(n --)
{
cin>>s>>t;
ss = "";
for(i = 0;i < s.size();i ++)
{
if(is(s[i])) ss += s[i];
}
int pre = ss.size(),len = s.size();
ans = "";
//cout<<ss<<" "<<s<<endl;
if(pre == 0)
{
ans += s[len-1];
bool f = 0;
while(t --)
{
ans[0] ++;
for(i = 0 ;i < len-1;i ++)
cout<<s[i];
cout<<ans<<endl;
if(is(ans[0])){f = 1; break;}
}
if(f){
while(t--){ans = inct(ans);
for(i = 0 ;i < len-1;i ++)
cout<<s[i];
cout<<ans<<endl;
}
}
}
else
{
while(t --){
ss = inct(ss);
//cout<<"dsa"<<endl;
int len = ss.size();
int j;
i = 0;
for(j = 0;j < s.size();j ++)
{
if(is(s[j])) {if(i==0) for(;i<=len -pre;i ++)cout<<ss[i];else cout<<ss[i++];}
else cout<<s[j];
}
cout<<endl;
}
}
cout<<endl;
}
}