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

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

What's the output?.

Post by _.B._ » Sun Apr 18, 2004 6:24 am

Subeen wrote:
7
too high
3
too high
7
too high
6
too high
7
too high
7
too high
6
right on
Greetings!.
What's the Output for this code??.
Thanks in advance.
_.

rlatif119
New poster
Posts: 16
Joined: Mon Mar 01, 2004 4:00 pm
Location: Dhaka

Post by rlatif119 » Fri May 28, 2004 7:21 pm

Well Well Well..........This problem is really a sily one. I am going to give you a hint, may be it will help you.
when "right on" is found (i don't care how you handle this string) just check that number for which right on is found is still untouched.
if yes-------->then stan is truthful.

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

ACed

Post by _.B._ » Sat May 29, 2004 6:47 am

Nothing like a good array of booleans to solve a problem :D
Thanks!
Keep posting!
_.

Jenn-Far Mei
New poster
Posts: 1
Joined: Fri Jul 02, 2004 9:16 am

Post by Jenn-Far Mei » Fri Jul 02, 2004 9:19 am

Frostina wrote:I try all the test datas
but my code is still wrong
plz help..
[c]#include <stdio.h>
int main(void) {
int n, ans, high = 10, low = 0;
char dir[20];
while (scanf("%d",&n)==1) {
if (!n) break;
scanf(" %[^\n]", dir);
if (!strcmp(dir,"too high"))
if (n<high) high = n;
if (!strcmp(dir,"too low"))
if (n>low) low = n;
if (!strcmp(dir,"right on")) {
if (n>=high||n<=low)
puts("Stan is dishonest");
else puts("Stan may be honest");
high = 10;
low = 0;
}
}
return 0;
}

[/c]
The initial value of high must be 11.

Pasa Yildirim
New poster
Posts: 14
Joined: Mon Mar 07, 2005 7:10 pm
Location: Bosnia and Herzegovina
Contact:

Post by Pasa Yildirim » Wed Mar 16, 2005 6:20 pm

Hello there.

Well, i have problem with 10530 (alwats WA). I test the program with all sample inputs here, but it doesn't work. Can anybody help me?

There is a code in cpp:
#include <cstdio>
#include <cstring>
using namespace std;

int main (void)
{
int number, h = 11, l = 0;

char word[20];

while (scanf("%d", &number))
{
if (number == 0) break;

scanf("%[^\n]", word);

if (strcmp(word, "too high") == 0)
{
if (number < h) h = number;
}
if (strcmp(word, "too low") == 0)
{
if (number > l) l = number;
}
if (strcmp(word, "right on") == 0)
{
if (number >= h || number <= l) printf("Stan is dishonest\n");
else printf("Stan may be honest\n");

h = 10, l = 0;
}
}

return 0;
}

rahurprem
New poster
Posts: 10
Joined: Mon Mar 28, 2005 5:59 pm
Location: Dhaka, Bangladesh
Contact:

10530

Post by rahurprem » Sat Apr 23, 2005 9:08 pm

I don't understand why judge is giving Wrong answer?

Code: Select all

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

int  a[20];

void makeTrue()
{
      for(int i=1; i<=10; i++)
           a[i]=1;
}

int testTrue()
{  
     for(int i=1; i<=10; i++)
    {
           if(a[i]==1)return 1;
    }
  return 0;
}


int main()
{
	//freopen("10530.txt","r",stdin);

  int N;
  char NN[20];
  char msg[20];

  
  makeTrue();
  while(scanf("%d\n",&N)==1 && N)
  {
   
            scanf("%[^\n]", msg);

	  

      if(strcmp(msg,"too high")==0)
	{
	  for(int i=N; i<=10; i++)
	    {
	      a[i]=0;
	    }
	}
      else if(strcmp(msg,"too low")==0)
	{
	  for(int i=N; i>=1; i--)
	    {
	      a[i]=0;
	    }
	}
     else if(strcmp(msg,"right on")==0)
	{
	  if(testTrue())
	    {
	      printf("Stan may be honest\n");
	    }
	  else
	    {
	      printf("Stan is dishonest\n");
	    }
	  makeTrue();
	}
    }
  return 0;
}

Thank you in advance.
Ashis
Programmer? No, no, i am a speedy typist.

sidky
New poster
Posts: 50
Joined: Wed Nov 06, 2002 1:37 pm
Location: Planet Earth, Universe
Contact:

Post by sidky » Sun Apr 24, 2005 1:06 am

Your testTrue() is wrong. check this

Code: Select all

5
too low
5
right on
0
the answer will be "Stan is dishonest"

rahurprem
New poster
Posts: 10
Joined: Mon Mar 28, 2005 5:59 pm
Location: Dhaka, Bangladesh
Contact:

Problem with 10530 is solved

Post by rahurprem » Sun Apr 24, 2005 7:53 pm

Thank you very much sidky.

I only changed the "right on" clause.

Code: Select all

........
else if(strcmp(msg,"right on")==0)
{		 
       if(testTrue() && a[N])
      {
             printf("Stan may be honest\n");
      }
      else
      {
	    printf("Stan is dishonest\n");
      }
      makeTrue();
}
............

Ashis[/i]
Programmer? No, no, i am a speedy typist.

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz » Tue Aug 09, 2005 12:34 am

Here's more test cases
INPUT

Code: Select all

10
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on
9
too low
8
too low
7
too low
10
right on
7
too high
7
right on
1
too low
2
too high
3
right on
3
too high
8
too high
1
too low
2
right on
5
right on
10
too low
9
too high
6
right on
0
OUTPUT

Code: Select all

Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Hope it helps
keep it real!

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

Post by Schutzstaffel » Sat Jan 07, 2006 3:46 am

I've read this thread and tested all cases mentioned but still get WA :o

Code: Select all

10
too high
3
too low
4
too high
2
right on
5
too low
7
too high
6
right on
9
too low
8
too low
7
too low
10
right on
7
too high
7
right on
1
too low
2
too high
3
right on
3
too high
8
too high
1
too low
2
right on
5
right on
10
too low
9
too high
6
right on
8
right on
9 
too low
8 
too low
7 
too low
8 
right on 
5
too low
5
right on
0 
OUTPUT:

Code: Select all

Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Did I miss something?
Thanks
Image

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz » Sat Jan 07, 2006 2:16 pm

yes indeed!

my output differ from your!
Try to rethink one before last test case

Code: Select all

9
too low
8
too low
7
too low
8
right on
the correct answer is : "Stan is dishonest"

Regards & hope it helps
keep it real!

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

Post by Schutzstaffel » Sat Jan 07, 2006 4:25 pm

Thanks! I corrected that but I still get WA

The corrected output:

Code: Select all

Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Stan is dishonest
Stan may be honest
Stan may be honest
Stan is dishonest
Stan may be honest
Stan is dishonest
Stan is dishonest
Are there more cases to test besides the ones I used for input?
Image

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz » Sat Jan 07, 2006 10:46 pm

maybe try this:

INPUT

Code: Select all

7
too low
8
too high
9
right on
1
too high
7
too low
8
right on
5
too low
8
too high
7
too high
5
right on
10
right on
10
too low
1
too high
5
right on
4
too high
3
too high
5
right on
6
too low
7
too low
5
right on
4
too low
1
too low
6
too high
9
too high
5
right on
1
too low
1
right on
10
too high
10
right on
5
too low
8
too high
7
too high
6
too high
5
too low
6
right on
0
OUTPUT

Code: Select all

Stan is dishonest
Stan is dishonest
Stan is dishonest
Stan may be honest
Stan is dishonest
Stan is dishonest
Stan is dishonest
Stan may be honest
Stan is dishonest
Stan is dishonest
Stan is dishonest
Good luck
keep it real!

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

Post by Schutzstaffel » Sat Jan 07, 2006 11:27 pm

Weird, it gives the same output as yours :?
Thanks for your help.
Image

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz » Mon Jan 09, 2006 1:55 am

So maybe you make some mistake in taking input?
I mean are you testing your prog using file stream or you just type whole input using keybord
If yes try to read in from file
If it won't help then you must rethink your algo

Regards
keep it real!

Post Reply

Return to “Volume 105 (10500-10599)”