Page 3 of 4

Posted: Mon Jan 09, 2006 2:04 am
by Schutzstaffel
I'm reading from a file.
I'll rethink the algo then, thanks.

Why WA?

Posted: Tue Dec 26, 2006 8:03 pm
by vijay03
My code gives correct output for all the input given in this forum. But i still get WA. I also tried changing how i get the input. Again WA. Could someone please help?

Code: Select all


Cut after ACC


Posted: Sun Jan 07, 2007 2:36 am
by Hank00544
Input :
10
too high
3
too low
3
too high
4
right on
0
Output :
Stan is dishonest

Posted: Sun Jan 07, 2007 11:06 am
by vijay03
My code gives the correct output to your input also.

Posted: Sat Jan 13, 2007 11:48 am
by Hank00544
vijay03 wrote:My code gives the correct output to your input also.
Try this.
Input :
10
too high
9
too high
9
right on
0
Output :
Stan is dishonest

Thanks a lot!

Posted: Sat Jan 13, 2007 1:01 pm
by vijay03
Thanks a lot Hank! Your i/o showed my error at once. Fixed it and got accepted! :) Thanks a lot!

I am getting WA. Please help

Posted: Wed Jul 18, 2007 11:07 pm
by abhiramn

Code: Select all

ACCEPTED
Everyone, please remember to check this case even.
INPUT:-

Code: Select all

8
too high
8
too low
9
right on
0
OUTPUT:-

Code: Select all

Stan is dishonest

WA(10530)[Problem E: Guessing Game]

Posted: Sat Sep 01, 2007 10:53 am
by ishtiaq ahmed
I am facing WA. Plz help me. Here is my code

Code: Select all

cut after AC.

10530 - Guessing Game

Posted: Sat May 24, 2008 1:33 pm
by zobayer

Code: Select all

AC
Thanks all who tried to help :)

Re: 10530 - Guessing Game

Posted: Sun May 25, 2008 8:15 am
by Obaida
Check this input.

Input:

Code: Select all

9
too low
8
too low
7
too low
10
right on
Output:

Code: Select all

Stan may be honest
>>Hope you get Accepted

10530 - Guessing Game

Posted: Mon Sep 08, 2008 12:17 pm
by anondo_iut
thanxs kabir. now i got ac :D .
i am really weak in using bool type array. :cry:
anyway. thank u again.

Re: 10530 - Guessing Game

Posted: Tue Sep 09, 2008 1:29 am
by kbr_iut
ur program fails for this input set.

Code: Select all

10
right on
5
too low
8
too high
7
too high
6
too high
5
too low
6
right on
10
right on
5
too low
8
too high
7
too high
6
too high
5
too low
6
right on
0

ur program gives

Code: Select all

Stan is dishonest
Stan is dishonest
Stan may be honest
Stan is dishonest

correct output should be

Code: Select all

Stan may be honest
Stan is dishonest
Stan may be honest
Stan is dishonest

another thing is that to solve this program u dont need to use two dimentioal array.Anyway,u may follow these rules.
1)just take an boolean array.
2)make all false
3)when u encounter too high make all upper cells true
4)when u encounter too low make all lower cells true.
5)when u encounter right on just check that cell is true or not.if true output "Stan is dishonest" if false output "Stan may be honest"
dont forget to make the array false when u start a new guessing.
i hope it will help.

Re: 10530 - Guessing Game

Posted: Sat Dec 10, 2011 6:22 pm
by avatar
hellow everyone.....

i am getting WA.. but why....
i can handle all the test cases in this foram ...
someone please help..........................
[/c]
#include <stdio.h>
int main()
{
int lower[150],higher[150],right[150];
int input,ar[10000];
char f[15],s[15];
int h=0,l=0,r=0,flag,k,c=0;
freopen("in10530.txt","r",stdin);
while(scanf("%d",&input)==1 && input!=0){

scanf("%s %s\n",&f,&s);
if(strcmp(f,"too")==0&&strcmp(s,"high")==0){
higher[h]=input;
h++;
}
if(strcmp(f,"too")==0&&strcmp(s,"low")==0){
lower[l]=input;
l++;
}
if(strcmp(f,"right")==0&&strcmp(s,"on")==0){
flag=1;
for(k=0;k<h;k++){
if(higher[k]<input||higher[k]==input){
flag=0;
break;
}
}
for(k=0;k<l;k++){
if(lower[k]>input||lower[k]==input){
flag=0;
break;
}

}

if(flag==0){
if(c!=0)printf("\n");
c=1;
printf("Stan is dishonest");
}
else if(flag==1){
if(c!=0)printf("\n");
c=1;
printf("Stan may be honest");
}
h=0;
l=0;
}

}



return 0;
}

thank u..................

and my algorithm is::
1.after taking the input if its too high then i am storing it in higher array
2.after taking the input if its too low then i am storing it in lower array
3.and if right on then
4.if any number in higher array is equal or less then right on number
5.if any number in lower array is equal or greater then right on number
6.if fulfill then "may honest"
7. else "dishonest"

uva problem no:10530

Posted: Mon Dec 26, 2011 3:51 pm
by snape
getting WA. plz help :(


#include <stdio.h>
#include <string.h>


long int right,high=8888,low=0,i=0,pre_high,pre_low,h=0;
char status[20],hg[1000],lw[1000];

int main()
{
int guess_num;
while(1)
{
if(guess_num==0)
break;

scanf("%d",&guess_num);
getchar();
gets(status);

if(strcmp(status,"too high")==0)
{
high=guess_num;
pre_high=high;
if(high<pre_low)
{
h=1;
}


}
else if(strcmp(status,"too low")==0)
{
low=guess_num;
pre_low=low;
if(low>pre_low)
{h=1;
}
}
else if(strcmp(status,"right on")==0)
{
right=guess_num;
if(h==1)
goto P;
if((high>right) && (low<right))
printf("Stan may be honest\n");
else
{P:
printf("Stan is dishonest\n");}

}


}


return 0;

}

Re: uva problem no:10530

Posted: Wed Jan 11, 2012 9:54 pm
by brianfry713

Code: Select all

int guess_num;
while(1)
{
if(guess_num==0)
break;
This section of your code causes the program to exit before reading or printing anything.