10530 - Guessing Game

All about problems in Volume 105. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Schutzstaffel
New poster
Posts: 37
Joined: Fri Apr 30, 2004 6:52 pm
Location: Portugal

Post by Schutzstaffel » Mon Jan 09, 2006 2:04 am

I'm reading from a file.
I'll rethink the algo then, thanks.
Image

vijay03
New poster
Posts: 33
Joined: Wed Sep 13, 2006 6:46 pm
Contact:

Why WA?

Post by vijay03 » Tue Dec 26, 2006 8:03 pm

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

Last edited by vijay03 on Sat Jan 13, 2007 1:02 pm, edited 1 time in total.

Hank00544
New poster
Posts: 3
Joined: Sun Jan 07, 2007 2:17 am

Post by Hank00544 » Sun Jan 07, 2007 2:36 am

Input :
10
too high
3
too low
3
too high
4
right on
0
Output :
Stan is dishonest

vijay03
New poster
Posts: 33
Joined: Wed Sep 13, 2006 6:46 pm
Contact:

Post by vijay03 » Sun Jan 07, 2007 11:06 am

My code gives the correct output to your input also.

Hank00544
New poster
Posts: 3
Joined: Sun Jan 07, 2007 2:17 am

Post by Hank00544 » Sat Jan 13, 2007 11:48 am

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

vijay03
New poster
Posts: 33
Joined: Wed Sep 13, 2006 6:46 pm
Contact:

Thanks a lot!

Post by vijay03 » Sat Jan 13, 2007 1:01 pm

Thanks a lot Hank! Your i/o showed my error at once. Fixed it and got accepted! :) Thanks a lot!

abhiramn
New poster
Posts: 29
Joined: Sat May 26, 2007 7:54 pm

I am getting WA. Please help

Post by abhiramn » Wed Jul 18, 2007 11:07 pm

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

ishtiaq ahmed
Learning poster
Posts: 53
Joined: Sat Jul 29, 2006 7:33 am
Location: (CSE,DU), Dhaka,Bangladesh

WA(10530)[Problem E: Guessing Game]

Post by ishtiaq ahmed » Sat Sep 01, 2007 10:53 am

I am facing WA. Plz help me. Here is my code

Code: Select all

cut after AC.
No venture no gain

with best regards
------------------------
ishtiaq ahmed

zobayer
Experienced poster
Posts: 110
Joined: Tue May 06, 2008 2:18 pm
Location: CSE-DU, Bangladesh
Contact:

10530 - Guessing Game

Post by zobayer » Sat May 24, 2008 1:33 pm

Code: Select all

AC
Thanks all who tried to help :)
Last edited by zobayer on Sat Jul 31, 2010 9:08 pm, edited 1 time in total.
You should not always say what you know, but you should always know what you say.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 10530 - Guessing Game

Post by Obaida » Sun May 25, 2008 8:15 am

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
try_try_try_try_&&&_try@try.com
This may be the address of success.

anondo_iut
New poster
Posts: 3
Joined: Sun Sep 07, 2008 6:25 pm

10530 - Guessing Game

Post by anondo_iut » Mon Sep 08, 2008 12:17 pm

thanxs kabir. now i got ac :D .
i am really weak in using bool type array. :cry:
anyway. thank u again.
Last edited by anondo_iut on Tue Sep 09, 2008 12:40 pm, edited 1 time in total.

User avatar
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 10530 - Guessing Game

Post by kbr_iut » Tue Sep 09, 2008 1:29 am

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.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

avatar
New poster
Posts: 8
Joined: Wed Nov 16, 2011 6:44 pm

Re: 10530 - Guessing Game

Post by avatar » Sat Dec 10, 2011 6:22 pm

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"

snape
New poster
Posts: 5
Joined: Sat Dec 03, 2011 4:18 pm

uva problem no:10530

Post by snape » Mon Dec 26, 2011 3:51 pm

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;

}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: uva problem no:10530

Post by brianfry713 » Wed Jan 11, 2012 9:54 pm

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.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 105 (10500-10599)”