Try running your own program and pretending to be the computer, and that'll help you debug. There's a problem with your binary search that you'll be able to catch if you do that.
On Tue, Sep 3, 2019 at 9:21 AM Mohammad Shahwez < [email protected]> wrote: > #include<stdio.h> > #include<stdlib.h> > #include<string.h> > int test(); > int main() > { > int no_of_test; > scanf("%d",&no_of_test); > fflush(stdin); > while(no_of_test) > { > test(); > no_of_test--; > } > return 0; > } > > int test() > { > int a,b,n; > char str[15]; > scanf("%d %d",&a,&b); > fflush(stdin); > scanf("%d",&n); > fflush(stdin); > while(n) > { > fflush(stdout); > printf("%d\n",(a+b)/2); > scanf("%[^\n]",str); > fflush(stdin); > if(strcmp(str,"TOO_BIG")==0) > b=(a+b)/2; > else if(strcmp(str,"TOO_SMALL")==0) > a=(a+b)/2; > else if(strcmp(str,"CORRECT")==0) > return 0; > else if(strcmp(str,"WRONG_ANSWER")==0) > return(1); > n--; > } > return(2); > } > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/e246a0f6-12d2-40d2-8c17-738def9e4bd5%40googlegroups.com > <https://groups.google.com/d/msgid/google-code/e246a0f6-12d2-40d2-8c17-738def9e4bd5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAHaiWHMhYo8Ee-FdjPC4dCX4-BELzmrNTpFRVYMK_2qU2WUq5w%40mail.gmail.com.
