Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- char str[200001], buf[26], a, b, look[26];
- int n, m;
- scanf("%d%d%s", &n, &m, str);
- for(int i = 0; i < 26; ++i){
- buf[i] = i;
- //printf("%d", buf[i]);
- }
- while(m--){
- scanf(" %c %c", &a, &b);
- int temp = buf[a -'a'];
- buf[a - 'a'] = buf[b - 'a'];
- buf[b - 'a'] = temp;
- }
- /*for(int i = 0; i < 26; ++i){
- printf("%d ", buf[i]);
- }
- */
- for(int i = 0; i < 26; ++i){
- look[buf[i]] = i + 'a';
- }
- for(m = 0 ; m < n; ++m){
- str[m] = look[str[m] - 'a'];
- }
- puts(str);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment