Page 2 of 4

### What's the output?.

Posted: 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.

Posted: 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.

### ACed

Posted: Sat May 29, 2004 6:47 am
Nothing like a good array of booleans to solve a problem
Thanks!
Keep posting!

Posted: 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.

Posted: 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;
}

### 10530

Posted: 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

Posted: 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"

### Problem with 10530 is solved

Posted: 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]

Posted: 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

Posted: Sat Jan 07, 2006 3:46 am
I've read this thread and tested all cases mentioned but still get WA

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

Posted: 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

Posted: 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?

Posted: 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

Posted: Sat Jan 07, 2006 11:27 pm
Weird, it gives the same output as yours :?
Thanks for your help.

Posted: 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