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

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

10530 - Guessing Game

Post by Dominik Michniewski »

Could anyone tell me why this code provide me to WA ?
I think that I do all correct :(

Best regards
DM

----------------------------
[c]cutted off[/c]

I Acc this problem. I've done silly mistake .... To all who don't get Acc: think about such scenario:
9 too low
8 too low
7 too low
8 right on
:)
Last edited by Dominik Michniewski on Fri Jul 11, 2003 12:12 pm, edited 1 time in total.
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Jalal
Learning poster
Posts: 65
Joined: Sun Jun 02, 2002 8:41 pm
Location: BANGLADESH
Contact:

Post by Jalal »

Why there will bbe right? :(
if(StrCmp(line,"right") == 0)
Why not right on 8)
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

"right" and "on" I scan as separate words, so I think, that I can compare only on of them to find answer ...
BTW. I try to compare both of them, but WA too

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
User avatar
Trickster
New poster
Posts: 6
Joined: Sat Sep 20, 2003 6:31 am
Location: Recife, Brazil

Post by Trickster »

I really don
Last edited by Trickster on Fri Oct 03, 2003 3:49 pm, edited 2 times in total.
"There's a difference between knowing the path, and walking the path."
Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:

Post by Subeen »

try the input
8 right on
0
output must be:
Stan may be honest
which ur program doesn't produce
razibcse
New poster
Posts: 50
Joined: Mon Jul 22, 2002 3:17 am
Location: SUST,BANGLADESH
Contact:

Post by razibcse »

this easy problem is really bugging me..I can't find where's my mistake...the output for the samples given here is correct in my program.

could u guys give me some more inputs u think may cause WA..

thanx anyway...

Razib
Wisdom is know what to do next; virtue is doing it.
zubair
New poster
Posts: 17
Joined: Fri Apr 18, 2003 2:22 pm

Post by zubair »

i think my code is right
pls point the error
[cpp]
arios
[/cpp]
Last edited by zubair on Fri Oct 24, 2003 8:04 pm, edited 1 time in total.
zubair-CUET old sailor
Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:

Post by Subeen »

zubair, check the input:
6
too high
6
too high
3
too low
2
too low
8
too high
10
too high
4
right on
output should be ? :wink:
zubair
New poster
Posts: 17
Joined: Fri Apr 18, 2003 2:22 pm

Post by zubair »

i think the answer is
stan may be honest.
my code passed your input. any other input.
zubair-CUET old sailor
Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:

Post by Subeen »

zubair,
replace gets(str);
with
scanf(" %[^\n]", str);
and u will get it AC
sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Strange :I find it :- (

Post by sumankar »

Code: Select all

[c]
sut off ...
[/c]
let me chk this
and BTW if i did offend anyone
by posting that stupid code
I am very^inf sorry.
:cry:
suman.
Last edited by sumankar on Wed Oct 22, 2003 9:51 pm, edited 1 time in total.
Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh
Contact:

Post by Subeen »

sumankar, ur program produces wrong output for this test case:
7
too high
3
too high
7
too high
6
too high
7
too high
7
too high
6
right on
zubair, please remove ur code from ur post.
sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Nothing

Post by sumankar »

Well i did not copy from
code pasted above
Thanks anyway for the help.
Suman.
Frostina
New poster
Posts: 23
Joined: Mon Dec 15, 2003 5:21 am

Post by Frostina »

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]
Thanks for your help ! ;)
sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Frostina

Post by sumankar »

Hi Frostina:
Try:

Code: Select all

[c]
while (scanf("%d\n",&n)==1) {[/c]
instead of

Code: Select all

[c]
while (scanf("%d",&n)==1) {[/c]
Never know!
Might just help, if algo is ok .
Suman. :wink:
Post Reply

Return to “Volume 105 (10500-10599)”