Advertisement
Saleh127

UVA 12897

May 14th, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12.  
  13. map<char,char>x;
  14.  
  15. string a;
  16. char b,c;
  17. x.clear();
  18. ll n,i,j,k,l;
  19.  
  20. cin>>a;
  21. cin>>n;
  22.  
  23. for(i=0;i<a.size();i++)
  24. {
  25. x[a[i]]=a[i];
  26. }
  27.  
  28. for(i=0;i<n;i++)
  29. {
  30. cin>>b>>c;
  31. for(char s='A';s<='Z';s++)
  32. {
  33. if(x[s]==c)
  34. {
  35. x[s]=b;
  36. }
  37. }
  38. }
  39. for(i=0;i<a.size();i++)
  40. {
  41. cout<<x[a[i]];
  42. }
  43. cout<<endl;
  44. }
  45.  
  46.  
  47. return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement