SHARE
TWEET

Snackdown_ROUND1A_Typing.c

codebuster10x Oct 22nd, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include<string.h>
  3.  
  4. int main(void)
  5. {
  6.     int t ;//test cases
  7.     scanf("%d",&t);
  8.  
  9.     while(t--)
  10.     {
  11.         int n,x=0;
  12.         scanf("%d",&n);//enter word length
  13.         char ch[20],a[2000]={'\0'};
  14.         static float time=0.0;
  15.         while(n--)
  16.         {
  17.         scanf("%s",ch);//enter the word
  18.         int i=0,j=0,k=0,flag=0;
  19.         int numlen=strlen(ch);
  20.         //static float time=0.0;
  21.         char* p;
  22.         p = strstr(a, ch);
  23.         //printf("%s\n",p);
  24.         a[x]='a';
  25.         x++;
  26.         for(j=0;j<numlen;j++)
  27.         {
  28.             a[x]=ch[j];
  29.             x++;
  30.         }
  31.  
  32.         //printf("%s\n",a);
  33.  
  34.         if(p)
  35.         {
  36.             float time1=0.0;
  37.             for(i=0;i<numlen;i++)
  38.          {
  39.             if(i==0)
  40.                 time1+=0.2;
  41.            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'))
  42.                 time1+=0.4;
  43.            else
  44.                 time1+=0.2;
  45.          }
  46.          time +=(time1)/2.0;
  47.          //printf("%.1f , added after searching\n",time);
  48.  
  49.         }
  50.         else
  51.         {
  52.         for(i=0;i<numlen;i++)
  53.         {
  54.             if(i==0)
  55.                 time+=0.2;
  56.            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'))
  57.                 time+=0.4;
  58.            else
  59.                 time+=0.2;
  60.         }
  61.  
  62.       // printf("%.2f\n",time);
  63.  
  64.     }
  65.         }
  66.      printf("%d\n",(int)(time*10.0));
  67.      time=0.0;
  68.      strcpy(a, " ");
  69.      strcpy(ch, " ");
  70.     }
  71.     return 0;
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top