I don't think the problem statement was ambiguous, at least if you are
somewhat used to linux.  You never need to create / folder because if it's
not there then I am not sure what state your linux system is in.  I am not
sure that is ever possible.  What you need to create are just strings
between /'s.  So I suppose you could think of the folder names as nodes in a
tree and of overall filesystem as a forest, with many roots.

The easiest and fastest way to solve this for me was to just use a set that
keeps track of full path names of already created folders, and all of their
parents until root folder.  This way you don't need to have any tree data
structure, and you can still do large input well under time limit.

For example when I am parsing folders from input statement that are supposed
to be created I send each string to a while loop that adds it to my set of
existing folders and all of its parents until it hits the "/" folder.  Then
when I am counting number of mkdirs for folders i need to create I have
similar while loop except I count how many times the path I pass is not
found in the set, and keep takings its parent folder until it is in the set
or i once again hit "/".

- Lev.


On Sun, May 23, 2010 at 2:58 AM, haibrenner <[email protected]> wrote:

> Ignore my previous post.
> I made a mistake.
>
>
> On May 23, 1:10 am, Carlos Guia <[email protected]> wrote:
> > My code, accepted in practice room gives 2, but the answer is clearly 1,
> but
> > I believe the input is invalid
> >
> > This list will include every directory already on your computer other
> than
> >
> > > the root directory. (The root directory is on every computer, so there
> is no
> > > need to list it explicitly.)
> >
> > I that means /home *must* be listed, so the case is
> > 1
> > 2 1
> > /home/gcj
> > /home
> > /home/x
> >
> > So even if someones code doesn't check for the case you posted should
> give
> > correct answer to a valid input.
> >
> > Carlos Guía
> >
> > On Sat, May 22, 2010 at 6:06 PM, Mikhail Dektyarev <
> >
> >
> >
> > [email protected]> wrote:
> > > Correct output is
> > > Case #1: 1
> > > because we need to create catalog "/home/x"
> >
> > > On Sat, May 22, 2010 at 11:55 PM, Paulo Cezar Pereira Costa <
> > > [email protected]> wrote:
> >
> > >> I was taking a look at Gluk's code for problem A,
> > >> seems like his code generate a wrong output, or I didn't understood
> the
> > >> problem statement..
> >
> > >> The case:
> > >> 1
> > >> 1 1
> > >> /home/gcj
> > >> /home/x
> >
> > >> What's the correct output ?
> >
> > >> On Sat, May 22, 2010 at 3:41 PM, Bharath Balakrishnan <
> > >> [email protected]> wrote:
> >
> > >>> I am not sure about a tree. But a greedy approach that creates the
> > >>> required directories in increasing order of the number of  separators
> '/' in
> > >>> the name, works.
> >
> > >>> On Sun, May 23, 2010 at 12:03 AM, Abdelrhman Abotaleb <
> > >>> [email protected]> wrote:
> >
> > >>>> Is the answer of the first problem needs a general tree !?
> > >>>> could any one provide me with a suitable splitting c++ code with a
> > >>>> dilemeter
> > >>>> thanks a lot
> >
> > >>>> --
> > >>>> Regards,
> > >>>> Abdelrhman.M. Abotaleb
> >
> > >>>> IEEE 2010 Student Chapter,
> > >>>> AC Active member
> > >>>> SPE 2009 Well Services Moderator
> > >>>> cairo.spe.org
> >
> > >>>> Major: Electronics & Communications
> > >>>> Minor: Computer Engineering
> >
> > >>>> --
> > >>>> You received this message because you are subscribed to the Google
> > >>>> Groups "google-codejam" group.
> > >>>> To post to this group, send email to [email protected].
> > >>>> To unsubscribe from this group, send email to
> > >>>> [email protected]<google-code%[email protected]>
> <google-code%[email protected]<google-code%[email protected]>
> >
> > >>>> .
> > >>>> For more options, visit this group at
> > >>>>http://groups.google.com/group/google-code?hl=en.
> >
> > >>> --
> > >>> Regards,
> > >>> Bharath B
> >
> > >>> "When the going gets tough, the tough get going"
> >
> > >>>  --
> > >>> You received this message because you are subscribed to the Google
> Groups
> > >>> "google-codejam" group.
> > >>> To post to this group, send email to [email protected].
> > >>> To unsubscribe from this group, send email to
> > >>> [email protected]<google-code%[email protected]>
> <google-code%[email protected]<google-code%[email protected]>
> >
> > >>> .
> > >>> For more options, visit this group at
> > >>>http://groups.google.com/group/google-code?hl=en.
> >
> > >> --
> > >> Paulo Cezar Pereira Costa
> > >> Graduando em Ciência da Computação
> > >> Universidade Federal de Goiás
> >
> > >>  --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "google-codejam" group.
> > >> To post to this group, send email to [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected]<google-code%[email protected]>
> <google-code%[email protected]<google-code%[email protected]>
> >
> > >> .
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/google-code?hl=en.
> >
> > > --
> > > Best regards, Дектярев Михаил
> >
> > >  --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "google-codejam" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-code%[email protected]>
> <google-code%[email protected]<google-code%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-code?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<google-code%[email protected]>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/google-code?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-code%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to