Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<string.h>
- int main(void)
- {
- int t ;//test cases
- scanf("%d",&t);
- while(t--)
- {
- int n,x=0;
- scanf("%d",&n);//enter word length
- char ch[20],a[2000]={'\0'};
- static float time=0.0;
- while(n--)
- {
- scanf("%s",ch);//enter the word
- int i=0,j=0,k=0,flag=0;
- int numlen=strlen(ch);
- //static float time=0.0;
- char* p;
- p = strstr(a, ch);
- //printf("%s\n",p);
- a[x]='a';
- x++;
- for(j=0;j<numlen;j++)
- {
- a[x]=ch[j];
- x++;
- }
- //printf("%s\n",a);
- if(p)
- {
- float time1=0.0;
- for(i=0;i<numlen;i++)
- {
- if(i==0)
- time1+=0.2;
- else if((ch[i-1]=='d'&&ch[i]=='f')||(ch[i-1]=='f'&&ch[i]=='d')||(ch[i-1]=='j'&&ch[i]=='k')||(ch[i-1]=='k'&&ch[i]=='j') || (ch[i-1]=='d'&&ch[i]=='d') || (ch[i-1]=='f'&&ch[i]=='f') || (ch[i-1]=='j'&&ch[i]=='j') || (ch[i-1]=='k'&&ch[i]=='k'))
- time1+=0.4;
- else
- time1+=0.2;
- }
- time +=(time1)/2.0;
- //printf("%.1f , added after searching\n",time);
- }
- else
- {
- for(i=0;i<numlen;i++)
- {
- if(i==0)
- time+=0.2;
- else if((ch[i-1]=='d'&&ch[i]=='f')||(ch[i-1]=='f'&&ch[i]=='d')||(ch[i-1]=='j'&&ch[i]=='k')||(ch[i-1]=='k'&&ch[i]=='j') || (ch[i-1]=='d'&&ch[i]=='d') || (ch[i-1]=='f'&&ch[i]=='f') || (ch[i-1]=='j'&&ch[i]=='j') || (ch[i-1]=='k'&&ch[i]=='k'))
- time+=0.4;
- else
- time+=0.2;
- }
- // printf("%.2f\n",time);
- }
- }
- printf("%d\n",(int)(time*10.0));
- time=0.0;
- strcpy(a, " ");
- strcpy(ch, " ");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment