10530 - Guessing Game
Moderator: Board moderators
-
- New poster
- Posts: 37
- Joined: Fri Apr 30, 2004 6:52 pm
- Location: Portugal
Why WA?
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.
Thanks a lot!
Thanks a lot Hank! Your i/o showed my error at once. Fixed it and got accepted!
Thanks a lot!
![:)](./images/smilies/icon_smile.gif)
I am getting WA. Please help
Code: Select all
ACCEPTED
INPUT:-
Code: Select all
8
too high
8
too low
9
right on
0
Code: Select all
Stan is dishonest
-
- Learning poster
- Posts: 53
- Joined: Sat Jul 29, 2006 7:33 am
- Location: (CSE,DU), Dhaka,Bangladesh
WA(10530)[Problem E: Guessing Game]
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
with best regards
------------------------
ishtiaq ahmed
-
- Experienced poster
- Posts: 110
- Joined: Tue May 06, 2008 2:18 pm
- Location: CSE-DU, Bangladesh
- Contact:
10530 - Guessing Game
Code: Select all
AC
![:)](./images/smilies/icon_smile.gif)
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.
Re: 10530 - Guessing Game
Check this input.
Input:
Output:
>>Hope you get Accepted
Input:
Code: Select all
9
too low
8
too low
7
too low
10
right on
Code: Select all
Stan may be honest
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
-
- New poster
- Posts: 3
- Joined: Sun Sep 07, 2008 6:25 pm
10530 - Guessing Game
thanxs kabir. now i got ac
.
i am really weak in using bool type array.
anyway. thank u again.
![:D](./images/smilies/icon_biggrin.gif)
i am really weak in using bool type array.
![:cry:](./images/smilies/icon_cry.gif)
anyway. thank u again.
Last edited by anondo_iut on Tue Sep 09, 2008 12:40 pm, edited 1 time in total.
-
- Experienced poster
- Posts: 103
- Joined: Tue Mar 25, 2008 11:00 pm
- Location: IUT-OIC, DHAKA, BANGLADESH
- Contact:
Re: 10530 - Guessing Game
ur program fails for this input set.
ur program gives
correct output should be
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.
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
Code: Select all
Stan is dishonest
Stan is dishonest
Stan may be honest
Stan is dishonest
Code: Select all
Stan may be honest
Stan is dishonest
Stan may be honest
Stan is dishonest
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...............................
It is more tough to become a good person.
I am trying both...............................
Re: 10530 - Guessing Game
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"
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
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;
}
![:(](./images/smilies/icon_frown.gif)
#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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: uva problem no:10530
Code: Select all
int guess_num;
while(1)
{
if(guess_num==0)
break;
Check input and AC output for thousands of problems on uDebug!