nelson33

Untitled

Oct 30th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. char str[1000005],change[100005],change2[100005];
  4. int type[100005],detect[1000005];
  5. int  main(){
  6.     gets(str);
  7.     int Q,detect[26];
  8.     for(int i=0;i<1000005;i++) detect[i]=0;
  9.     scanf("%d",&Q);
  10.     char table[26];
  11.     for(int i=0;i<26;i++){
  12.         table[i] = 'a' + i;
  13.     }
  14.     for(int i=0;i<Q;i++){
  15.         scanf("%d %c %c",&type[i],&change[i],&change2[i]);
  16.     }
  17.     for(int i =Q-1;i>-1;i--){
  18.         if(type[i] ==2){
  19.             int temp =change[i]-48;
  20.             if(detect[temp] ==0){
  21.                 str[temp] =change2[i];
  22.                 detect[temp] =1;
  23.             }          
  24.         }
  25.         if(type[i]==1){
  26.             int temp2=change[i]-'a';
  27.             int temp3=change2[i]-'a';
  28.             table[temp2]=table[temp3];
  29.         }
  30.     }  
  31.     int len=strlen(str);
  32.     for(int i=0;i<len;i++) printf("%c",table[str[i]-'a']);
  33.     printf("\n");
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment