#K65857. Smart Home Device Management
Smart Home Device Management
Smart Home Device Management
You are required to implement a smart home system to manage various devices. The system supports commands to turn devices on, off, and set them to standby. Additionally, the system should be able to query the status of a device and list devices by their state.
The commands are as follows:
- TURN_ON <device>: Turn the specified device on.
- TURN_OFF <device>: Turn the specified device off.
- STANDBY <device>: Set the specified device to standby mode.
- STATUS <device>: Query the current status of the specified device. If the device is not registered, its status is
OFF
. - LIST_ON: List all devices that are currently on.
- LIST_OFF: List all devices that are currently off.
- LIST_STANDBY: List all devices that are in standby mode.
The state of a device, denoted by \( S \), can be one of the following: \[ S \in \{\text{ON}, \text{OFF}, \text{STANDBY}\} \]
When executing a sequence of commands, the system should process them in order and produce output only for the commands that request information (STATUS
, LIST_ON
, LIST_OFF
, and LIST_STANDBY
). The overall result is the JSON array representation of these outputs.
For example, given the following sequence:
TURN_ON Television TURN_ON Lamp STANDBY Television TURN_OFF Lamp STATUS Television STATUS Lamp LIST_ON LIST_OFF LIST_STANDBY
The output should be:
["STANDBY", "OFF", [], ["Lamp"], ["Television"]]
inputFormat
The input is given from stdin
and consists of a series of commands separated by newlines. Each command follows one of the formats described above. The input ends at EOF.
outputFormat
The output should be printed to stdout
as a JSON array representation of the results for each STATUS
and LIST
command in the order they are encountered.
For example, for the sample given in the description, the output should be:
["STANDBY", "OFF", [], ["Lamp"], ["Television"]]## sample
TURN_ON Television
STATUS Television
LIST_OFF
["ON", []]