U didn't understand my problem.....i have the problem with this line --

"The length of the needle is only limited by the memory available to your
program, so do not make any assumptions - instead, read the length and
allocate memory as needed."

On Sun, Mar 13, 2011 at 4:00 PM, sukhmeet singh <sukhmeet2...@gmail.com>wrote:

> in order to deal with such situations u have to read the input till the end
> of file
> if your algo is correct then using EOF something like
> while(scanf("%d",&n)!=EOF) will give u AC..!!
>
> On Sun, Mar 13, 2011 at 2:01 PM, Logic King <crazy.logic.k...@gmail.com>wrote:
>
>>  I tried the problem https://www.spoj.pl/problems/NHAY/
>>
>> I didn't Understand the Input of the problem --
>> The length of the needle is only limited by the memory available to your
>> program, so do not make any assumptions - instead, read the length and
>> allocate memory as needed. The haystack is *not* limited in size, which
>> implies that your program should not read the whole haystack at once. The
>> KMP algorithm is stream-based, i.e. it processes the haystack character by
>> character, so this is not a problem.
>>
>> my code works fine i the size of both the strings are limited
>>
>> i created my own algo...didn't did it by KMP.....plz help me how to
>> control the large input !!
>>
>>
>> my code is--
>>
>> #include<stdio.h>
>> #include<string.h>
>>
>> int main()
>> {
>>     int t,i,j,n,l1,l2;
>>     char p[10000000],str[10000000];
>>     scanf("%d",&t);
>>     while(t--)
>>     {
>>         scanf("%d",&n);
>>         i=0;
>>         scanf("%s",p);
>>         scanf("%s",str);
>>         l1=strlen(str);l2=strlen(p);
>>         for(j=0;j<l2;)
>>         {
>>
>>                 if(i<l1)
>>                 {
>>                     if(str[i]==p[j])
>>                     {
>>                         if(j==l2-1)
>>                         {
>>                         printf("%d\n",i-l2+1);
>>                         j=0;
>>                         i=i-l2+2;
>>                         }
>>                         else
>>                         {
>>                         i++;
>>                         j++;
>>                         }
>>                     }
>>                     else
>>                     {
>>                         if(j==0)
>>                             i++;
>>                         else
>>                             j=0;
>>                     }
>>                 }
>>                 else
>>                     break;
>>         }
>>         printf("\n");
>>     }
>> return 0;
>> }
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to