Getting correct answer in my compiler but showing wrong answer when submiiting.

june long challenge SHKSTR
third question
#include<stdio.h>
#include<string.h>
int main()
{
long int i,n;
char str[100000][10];
scanf("%ld",&n);
for(i=1;i<=n;i++)
scanf("\n%s",str[i]);
long int queries,j;
scanf("\n%ld",&queries);
long int query[queries];
char str1[queries][10];
for(j=1;j<=queries;j++)
{
scanf("\n%ld %s",&query[j],str1[j]);
}
for(j=1;j<=queries;j++)
{
printf("\n%d",query[j]);
}
for(j=1;j<=queries;j++)
{
printf("\n%d",str1[j]);
}
for(j=1;j<=queries;j++)
{
int count=0,k=1,p=0,q,l;
for(l=1;l<=query[j];l++)
{
while(str[l][k]==str1[j][k])
{
count++;
k++;
}
if(l==1)
{
q=1;
p=count;
}
else
{
if(count>p)
{
q=l;
p=count;
}
}
count=0;
k=1;
}
puts(str[q]);
}
return 0;
}

  • List item


Everyone, this contest is live so don’t help!! @its_sk_91 Please remove your code from here, Will help you after the contest

1 Like

the same is happening for me too, i need to submit soon… any suggestion? i’m guessing that the compiler is trying to give input in a different form.

Please help!