Solve of UVA 12897:
Decoding Baby Boos |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,k,l,tst,m;
char y[1000000],a,b,x[128];
cin>>tst;
while(tst--)
{
scanf("%s",&y);
scanf("%d",&n);
for(i=0;i<128;i++) x[i]=i;
while(n--)
{
cin>>a>>b;
for(i='A';i<='Z';i++)
{
if(x[i]==b) x[i]=a;
}
}
for(i=0;y[i];i++)
{
printf("%c",x[y[i]]);
}
printf("\n");
}
return 0;
}
No comments:
Post a Comment