10854 - Number of Paths

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

Moderator: Board moderators

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

Oops, sorry.
Then try these inputs instead. They're correct, I suppose.

Code: Select all

2
IF
IF
ELSE
END_IF
IF
ELSE
END_IF
ELSE
END_IF
ENDPROGRAM
IF
ELSE
IF
ELSE
END_IF
IF
ELSE
END_IF
END_IF
ENDPROGRAM
Outputs: 5, 5.
zhang
New poster
Posts: 11
Joined: Sun May 22, 2005 11:14 am

Post by zhang »

Thank u for your test data. I found a mistake and got AC.
Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

Thanks to mf for the test cases.
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

Problem seems to be easy ...
I got correct output for every case in this board (and sample IO too ;) ) but I got WA, when I send it.

Could anyone help me? I can't see my mistake :(
Basically (I can send code, if someone requests for it) my algorithm is:
count all leafs on tree created from if-else-end_if statements. Multiply results from each separate if-else-end_if statement occured on root level of program (level of endprogram keyword).

I cover all cases with multiply number of if statements in row on any deep in tree.
Maybe someone post tricky case I missed?

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)
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

I'm so stupid :(
I make silly mistake, I got Accepted now.

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)
hoang
New poster
Posts: 4
Joined: Sat Jan 14, 2006 6:02 pm

WA again ?

Post by hoang »

Code: Select all

1
IF
ELSE
IF
ELSE
IF
END_IF
END_IF
IF
END_IF
IF
ELSE
END_IF
END_IF
ENDPROGRAM
i got WA again. and plz see that test.
2 of my friend got accept but 1 have answer is 5 and another have 12 ( me 9 )

i dont know what is the right answer ?
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

That's not a correct input. Every IF must have an ELSE.
hoang
New poster
Posts: 4
Joined: Sat Jan 14, 2006 6:02 pm

sorry

Post by hoang »

Code: Select all

1
IF
ELSE
IF
ELSE
IF
END_IF
END_IF
IF
END_IF
IF
ELSE
END_IF
END_IF
END_IF
ENDPROGRAM
i think the result is 5 .
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: sorry

Post by Martin Macko »

hoang wrote:i think the result is 5 .
This input is not correct, too. The IF and END_IF statements must be ballanced.
solon_aguiar
New poster
Posts: 7
Joined: Mon Jun 08, 2009 11:16 pm

Re: 10854 - Number of Paths

Post by solon_aguiar »

Does anybody have other valuable inputs? My code passes all the inputs in this topic, but still getting WA.
solon_aguiar
New poster
Posts: 7
Joined: Mon Jun 08, 2009 11:16 pm

Re: 10854 - Number of Paths

Post by solon_aguiar »

Got it accepted. The following case was helpful in debugging:

Code: Select all

1
IF
ELSE
END_IF
S
S
S
IF
ELSE
IF
ELSE
END_IF
IF
ELSE
END_IF
S
S
S
S
S
IF
ELSE
END_IF
END_IF
ENDPROGRAM
Output is

Code: Select all

18
Post Reply

Return to “Volume 108 (10800-10899)”