problem Description
Give you the T Group of data, each set of data to give you a string, with only uppercase letters or underscores. Give you M-group operations, each set of operations have U, v two capital letters, that is, the string inside all the letter V into the letter U
idea: Turn B into a, turn a into C, it's equivalent to turn B into C. That an array to save the last letter into that letter
#include <bits/stdc++.h> using namespace std;
Char s[1000055];
int main () {int T, m;
Char c1[2], c2[2];
The int flag[30];//is used to save, and finally the letter becomes the letter scanf ("%d", &t);
while (t--) {scanf ("%s", s);
for (int i = 0; I <=; i++)//Initialize flag[i] = i;
scanf ("%d", &m);
while (m--) {scanf ("%s%s", C1, C2);
int u = c1[0]-' a ';//convert integer int v = c2[0]-' a ';
for (int i = 0; I <=; i++)//core {if (flag[i] = = v)//original flag[i] is the letter V, now let him become the letter U
{Flag[i] = u;
}}} int len = strlen (s);
for (int i = 0; i < len; i++) {if (S[i] >= ' A ' && s[i] <= ' Z ')//if uppercase {
int t = s[i]-' A ';
printf ("%c", flag[t] + ' A ');//output changed result} else printf ("%c", S[i]); } printf ("\ n");
} return 0;
}