#C6635. Task Management System
Task Management System
Task Management System
You are given a task management system simulator. The system supports several commands to add, update, and list tasks. Each task is represented by a name, a deadline (in the format \(YYYY-MM-DD\)), and a priority. There are four types of commands:
- add <task_name> <deadline> <priority>: Adds a new task with the given deadline and priority.
- update <task_name> <new_deadline> <new_priority>: Updates an existing task. Use the literal string "None" (without quotes) for any field you do not wish to change.
- list_deadline: Lists all tasks sorted by deadline in ascending order.
- list_priority: Lists all tasks sorted by priority. The priority order is defined as: \(\text{urgent} < \text{high} < \text{medium} < \text{low}\).
For every list command, the system outputs the current list of tasks as a JSON array. Each task is a JSON object with the keys name
, deadline
, and priority
.
Your program should read the commands from standard input and output the result for each list command to standard output.
inputFormat
The first line contains an integer \(n\) indicating the number of commands. Each of the next \(n\) lines contains a command. The command formats are as follows:
- add task_name deadline priority
- update task_name new_deadline new_priority (use the literal string "None" to indicate no change)
- list_deadline
- list_priority
outputFormat
For every list command encountered in the input, output a JSON array (on a new line) representing the list of tasks. Each task is an object with keys name
, deadline
, and priority
.
3
add task1 2023-12-01 high
add task2 2023-11-01 urgent
list_priority
[{"name": "task2", "deadline": "2023-11-01", "priority": "urgent"}, {"name": "task1", "deadline": "2023-12-01", "priority": "high"}]
</p>