Hi Neal & Parker,
Thanks a lot guys, I ran a testcase with an empty line at the end and as
you guys pointed out, it failed... I changed it the way you guys suggested,
it worked and got AC :)
Now, Can I improve my solution? I believe what I am doing in Update
function is overkill, plain BFS would suffice, right?
And I am more inclined to use maps, is there any other way in which I could
have represented the data better?
On Thursday, December 13, 2012 4:08:18 PM UTC+5:30, Porker wrote:
>
> Agree with Neal
>
> To read till the end of file, I would suggest to use
>
> while (cin >> str1 >> str2) {
> ..
> }
>
> and then there is no need to take care of the last 'endl'.
>
> the following code give me accepted.
>
> http://ideone.com/ORzXcK
>
> Parker
>
> On 2012/12/13 13:34, Neal Zane wrote:
> > Not sure but could be the last 'endl' for the last line you
> > intentionally avoided. Note that UVa reports WA on mis-formatting,
> > insteadof PE (long ago since host migration).
> >
> > The while loop judging cin.eof() could also fail it if the input file
> > has extra lines that althoughthe test cases are read but in the tail
> > there are some blanks, cin.eof() is true and you are still running and
> > the output could be corrupted.It's safer to use just:
> > while (cin >> str1 >> str2) {
> > ..
> > }
> >
> > The code logic looks fine to me(hard to tell though, UVa is lining up
> > judging queuefor now.)
> >
> > Regards
> >
> >
> > On Thu, Dec 13, 2012 at 11:55 AM, thefourtheye dIVi
> > <[email protected] <javascript:>
> > <mailto:[email protected]<javascript:>>>
>
> > wrote:
> >
> > Hi,
> >
> > I believe it is a very simple problem but still getting WA... :(
> >
> > Could you anyone please help me spotting the mistake?
> >
> > http://ideone.com/dAsYdK
> > --
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/google-code/-/oby3yZGxHncJ.
For more options, visit https://groups.google.com/groups/opt_out.