#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
vector<int> fibs;
void fib(){
fibs.push_back(1);
fibs.push_back(2);
unsigned int a=1,b=2,c=3;
while(c<1<<31){
fibs.push_back(c);
a=b;
b=c;
c+=a;
}
}
int main(){
int t;
cin>>t;
fib();
while(t--){
int n,nos;
cin>>n;
vector<int> pos(n);
for(int i=0;i<n;i++){
cin>>nos;
pos[i]=lower_bound(fibs.begin(),fibs.end(),nos)-fibs.begin();
// cout<<pos[i]<<endl;
}
string ans(100,' '),s;
ws(cin);
getline(cin,s);
for(int i=0,j=0;i<s.size()&&j<n;i++){
if(s[i]>='A'&&s[i]<='Z'){
ans[pos[j]]=s[i];
// cout<<pos[j]<<endl;
j++;
}
}
int i=ans.size()-1;
while(i>0&&(ans[i]<'A'||ans[i]>'Z'))
i--;
ans=ans.substr(0,i+1);
cout<<ans<<endl;
}
}
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
vector<int> fibs;
void fib(){
fibs.push_back(1);
fibs.push_back(2);
unsigned int a=1,b=2,c=3;
while(c<1<<31){
fibs.push_back(c);
a=b;
b=c;
c+=a;
}
}
int main(){
int t;
cin>>t;
fib();
while(t--){
int n,nos;
cin>>n;
vector<int> pos(n);
for(int i=0;i<n;i++){
cin>>nos;
pos[i]=lower_bound(fibs.begin(),fibs.end(),nos)-fibs.begin();
// cout<<pos[i]<<endl;
}
string ans(100,' '),s;
ws(cin);
getline(cin,s);
for(int i=0,j=0;i<s.size()&&j<n;i++){
if(s[i]>='A'&&s[i]<='Z'){
ans[pos[j]]=s[i];
// cout<<pos[j]<<endl;
j++;
}
}
int i=ans.size()-1;
while(i>0&&(ans[i]<'A'||ans[i]>'Z'))
i--;
ans=ans.substr(0,i+1);
cout<<ans<<endl;
}
}
Comments
Post a Comment