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],id[1000005];
- int main(){
- gets(str);
- int len=strlen(str);
- int Q;
- for(int i=0;i<len;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",&type[i]);
- int c1,c2;
- if(type[i]==2){
- scanf(" %d %c",&c1,&c2);
- id[i]=c1;
- change[i]=c2;
- }
- if(type[i]==1){
- scanf(" %c %c",&c1,&c2);
- change[i]=c1;
- change2[i]=c2;
- }
- }
- for(int i =Q-1;i>-1;i--){
- if(type[i] ==2){
- if(detect[id[i]] ==0){
- str[id[i]] =change2[i];
- detect[id[i]] =1;
- }
- }
- if(type[i]==1){
- int temp2=change[i]-'a';
- int temp3=change2[i]-'a';
- table[temp2]=table[temp3];
- }
- }
- 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