506 - System Dependencies

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

Moderator: Board moderators

506 System Dependencies

Postby dh3014 » Mon Apr 15, 2002 3:49 pm

I need correct output for following test data:
--
DEPEND A B C
DEPEND B D E G
DEPEND C G E K
DEPEND K Z
DEPEND E S
INSTALL A
LIST
REMOVE A
LIST
INSTALL B
INSTALL C
INSTALL A
REMOVE A
INSTALL K
LIST
REMOVE C
REMOVE A
INSTALL A
LIST
INSTALL C
REMOVE A
LIST
END

--
following are my program's output
--
DEPEND A B C
DEPEND B D E G
DEPEND C G E K
DEPEND K Z
DEPEND E S
INSTALL A
Installing Z
Installing K
Installing S
Installing E
Installing G
Installing C
Installing D
Installing B
Installing A
LIST
Z
K
S
E
G
C
D
B
A
REMOVE A
Removing A
Removing C
Removing K
Removing Z
Removing B
Removing G
Removing E
Removing S
Removing D
LIST
INSTALL B
Installing G
Installing S
Installing E
Installing D
Installing B
INSTALL C
Installing Z
Installing K
Installing C
INSTALL A
Installing A
REMOVE A
Removing A
INSTALL K
K is already installed.
LIST
G
S
E
D
B
Z
K
C
REMOVE C
Removing C
Removing K
Removing Z
REMOVE A
A is not installed.
INSTALL A
Installing Z
Installing K
Installing C
Installing A
LIST
G
S
E
D
B
Z
K
C
A
INSTALL C
C is already installed.
REMOVE A
Removing A
Removing C
Removing K
Removing Z
LIST
G
S
E
D
B
END
--

I think I did look at the problem description very carefully and several times. but after submit my problem, I got Runtime Error, I think it's because I don't allocate enough memory to restore each item's data. After I fixed it, I got Wrong Answer now... I tried several times but it didn't work, now I want to know...when we installing or removing some components, would their display order make the difference though it's a special judge problem?
Thanks anyway.
dh3014
New poster
 
Posts: 24
Joined: Tue Mar 26, 2002 2:00 am
Location: Taiwan

Postby wyvmak » Sun Jun 16, 2002 4:32 pm

i checked the output, the order is a bit different, but it looks ok. as it's claimed as a special judge problem, unless the judge program itself has problem.

maybe test your program on cases on components cannot be removed.

in installing A, my output would be:
INSTALL A
Installing D
Installing S
Installing E
Installing G
Installing B
Installing Z
Installing K
Installing C
Installing A
wyvmak
Experienced poster
 
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

506 - System Dependencies

Postby .. » Thu Feb 06, 2003 7:10 pm

I got many WA on this, going to be crazy :(
Can anyone provide some tricky case?
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
..
A great helper
 
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Postby little joey » Sat Feb 08, 2003 2:55 pm

Well, I got many, many WAs too, and still see no way out of it.

The thing that worries me most is the phrase
Likewise, a component, not explicitly installed, can be explicitly removed in response to a command (if it is not needed to support other components)


I cannot think of a situation where a component that is not explicitly installed, that is not needed by other components, can be still installed. It should be already removed when the components that depended on it where removed. Can anybody explain?
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby .. » Sat Feb 08, 2003 3:29 pm

Hi, I got it accepted.
I never think about the case you say, I think you are correct. There is no such situation.
I got accepted after correcting my "LIST" order.
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
..
A great helper
 
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Postby little joey » Sat Feb 08, 2003 3:59 pm

Congrats!
Been waisting the whole morning on this problem, and still no success...

Are there any catches concerning the list-order? My program produces exactly the same output for the sample cases as is given.
For the input
Code: Select all
INSTALL A
INSTALL B
REMOVE A
INSTALL A
LIST
END

my program gives
Code: Select all
INSTALL A
   Installing A
INSTALL B
   Installing B
REMOVE A
   Removing A
INSTALL A
   Installing A
LIST
   B
   A
END

which should be correct, according to the description. Or should the list-order be reversed?
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby .. » Sat Feb 08, 2003 4:27 pm

You are correct on that output.

Input:
Code: Select all
DEPEND A C B
DEPEND B C
INSTALL A
LIST
REMOVE A
END


Output:
Code: Select all
DEPEND A C B
DEPEND B C
INSTALL A
   Installing C
   Installing B
   Installing A
LIST
   C
   B
   A
REMOVE A
   Removing A
   Removing B
   Removing C
END
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
..
A great helper
 
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Postby little joey » Sat Feb 08, 2003 5:18 pm

That's exactly my output.
I give up on this problem. :cry:
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby Caesum » Sat Feb 08, 2003 5:35 pm

I had a similar experience on this problem some time ago, I can match all of the examples that have been given on the boards but unfortunately I am also WA on it :(
Caesum
Experienced poster
 
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK

Postby little joey » Sat Feb 08, 2003 6:18 pm

Well, it's maddening. There should be something that almost everybody is overlooking. I have confirmed that command words can also occur as component names, but I am almost certain my program handles them correctly.
Code: Select all
DEPEND REMOVE INSTALL DEPEND END LIST
INSTALL REMOVE
INSTALL END
LIST
END
should give
Code: Select all
DEPEND REMOVE INSTALL DEPEND END LIST
INSTALL REMOVE
   Installing INSTALL
   Installing DEPEND
   Installing END
   Installing LIST
   Installing REMOVE
INSTALL END
   END is already installed.
LIST
   INSTALL
   DEPEND
   END
   LIST
   REMOVE
END
and not
Code: Select all
DEPEND REMOVE INSTALL DEPEND END LIST
INSTALL REMOVE
   Installing INSTALL
   Installing REMOVE
INSTALL END
   Installing LIST
   Installing END
LIST
   INSTALL
   REMOVE
   LIST
   END
END


I also considered some exotic cases, but still on the wrong track.
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby Caesum » Sat Feb 08, 2003 10:52 pm

What about the following ?
DEPEND A B C
DEPEND B D E G
DEPEND C G E K
DEPEND K Z
DEPEND E S
INSTALL A
LIST
REMOVE A
LIST
INSTALL B
INSTALL C
INSTALL A
REMOVE A
INSTALL K
LIST
REMOVE C
REMOVE A
INSTALL A
LIST
INSTALL C
REMOVE A
LIST
END


My WA program gives
DEPEND A B C
DEPEND B D E G
DEPEND C G E K
DEPEND K Z
DEPEND E S
INSTALL A
Installing D
Installing S
Installing E
Installing G
Installing B
Installing Z
Installing K
Installing C
Installing A
LIST
D
S
E
G
B
Z
K
C
A
REMOVE A
Removing A
Removing B
Removing D
Removing C
Removing E
Removing S
Removing G
Removing K
Removing Z
LIST
INSTALL B
Installing D
Installing S
Installing E
Installing G
Installing B
INSTALL C
Installing Z
Installing K
Installing C
INSTALL A
Installing A
REMOVE A
Removing A
INSTALL K
K is already installed.
LIST
D
S
E
G
B
Z
K
C
REMOVE C
Removing C
Removing K
Removing Z
REMOVE A
A is not installed.
INSTALL A
Installing Z
Installing K
Installing C
Installing A
LIST
D
S
E
G
B
Z
K
C
A
INSTALL C
C is already installed.
REMOVE A
Removing A
Removing C
Removing K
Removing Z
LIST
D
S
E
G
B
END
Caesum
Experienced poster
 
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK

Postby little joey » Sun Feb 09, 2003 12:44 am

Exactly the same, line by line. I also tried 'crossing dependences' involving multiple levels and mixed levels, but al the answers seem sensible. Did several checks on the input, but found no flaws.
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby .. » Sun Feb 09, 2003 7:57 am

Just want to remind you two, do you handle that arbitrarily space may exist before and after the name of modules?
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
..
A great helper
 
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Postby Caesum » Sun Feb 09, 2003 12:26 pm

Well for something like
DEPEND.....A....B
INSTALL....A....
LIST......
REMOVE....B....
REMOVE.........A....
END

(I have replaced spaces by dots)
My program gives:
DEPEND.....A....B
INSTALL....A....
Installing B
Installing A
LIST......
B
A
REMOVE....B....
B is still needed.
REMOVE.........A....
Removing A
Removing B
END
Caesum
Experienced poster
 
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK

Postby little joey » Fri Apr 25, 2003 4:10 pm

2.5 months later I got AC, while looking at it all over again.

Just one hint for those still struggeling: look at my memory consumption... :wink:
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Next

Return to Volume V

Who is online

Users browsing this forum: No registered users and 1 guest