Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- char str[1000005],change[100005],change2[100005];
- int type[100005],detect[1000005];
- int main(){
- gets(str);
- int Q,detect[26];
- for(int i=0;i<1000005;i++) detect[i]=0;
- scanf("%d",&Q);
- char table[26];
- for(int i=0;i<26;i++){
- table[i] = 'a' + i;
- }
- for(int i=0;i<Q;i++){
- scanf("%d %c %c",&type[i],&change[i],&change2[i]);
- }
- for(int i =Q-1;i>-1;i--){
- if(type[i] ==2){
- int temp =change[i]-48;
- if(detect[temp] ==0){
- str[temp] =change2[i];
- detect[temp] =1;
- }
- }
- if(type[i]==1){
- int temp2=change[i]-'a';
- int temp3=change2[i]-'a';
- table[temp2]=table[temp3];
- }
- }
- int len=strlen(str);
- for(int i=0;i<len;i++) printf("%c",table[str[i]-'a']);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment