系统依赖 System Dependencies

题意翻译

###### 你的任务是模拟安装和卸载软件组件的过程。 ------------ ##### 指令如下: |指令|说明| | :----------- | :----------- | |DEPEND item1 item2 [item3..]|item1 依赖 item2,item3..(保证不存在循环依赖)| |INSTALL item1|安装item1及其依赖(不必重复安装)| |REMOVE item1|卸载item1及其依赖(不能卸载 还被其他显式安装的组件依赖的 组件)| |LIST|输出所有已安装的组件| |END|结束| 在INSTALL指令中提到的组件被显式安装,这些组件必须用REMOVE指令显式卸载。 被 显式安装的组件 直接或间接依赖的组件也不能在REMOVE指令中卸载。 ##### 输入: 每行一条指令,遵循以上规则。 ##### 输出: 对于每一行指令,首先输出一遍指令,接着按3空格的缩进输出本指令下进行的所有操作(详见PDF样例)。 操作的输出格式如下: |指令|输出| | :----------- | :----------- | |DEPEND|无| |INSTALL|Installing [item]| | |[item] is already installed.(显式安装时输出)| |REMOVE|Removing [item]| | |[item] is still needed.(显式卸载时输出)| | |[item] is not installed.(同上)| |LIST|已安装的组件名| |END|无| **--大部分翻译来自紫书**

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=7&page=show_problem&problem=447 [PDF](https://uva.onlinejudge.org/external/5/p506.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA506/68afb2e6189fd70cb0193c35ff218476f81b2b02.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA506/00dcbed06d6ffd4ce2337600ff18c4293150ef46.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA506/5eeafd9adb13e67e1498450a046ece96f8f7f995.png)

输入输出样例

输入样例 #1

DEPEND TELNET TCPIP NETCARD
DEPEND TCPIP NETCARD
DEPEND DNS TCPIP NETCARD
DEPEND BROWSER TCPIP HTML
INSTALL NETCARD
INSTALL TELNET
INSTALL foo
REMOVE NETCARD
INSTALL BROWSER
INSTALL DNS
LIST
REMOVE TELNET
REMOVE NETCARD
REMOVE DNS
REMOVE NETCARD
INSTALL NETCARD
REMOVE TCPIP
REMOVE BROWSER
REMOVE TCPIP
END

输出样例 #1

DEPEND TELNET TCPIP NETCARD
DEPEND TCPIP NETCARD
DEPEND DNS TCPIP NETCARD
DEPEND BROWSER TCPIP HTML
INSTALL NETCARD
Installing NETCARD
INSTALL TELNET
Installing TCPIP
Installing TELNET
INSTALL foo
Installing foo
REMOVE NETCARD
NETCARD is still needed.
INSTALL BROWSER
Installing HTML
Installing BROWSER
INSTALL DNS
Installing DNS
LIST
NETCARD
TCPIP
TELNET
foo
HTML
BROWSER
DNS
REMOVE TELNET
Removing TELNET
REMOVE NETCARD
NETCARD is still needed.
REMOVE DNS
Removing DNS
REMOVE NETCARD
NETCARD is still needed.
INSTALL NETCARD
NETCARD is already installed.
REMOVE TCPIP
TCPIP is still needed.
REMOVE BROWSER
Removing BROWSER
Removing HTML
Removing TCPIP
REMOVE TCPIP
TCPIP is not installed.
END