← 返回 rippling 的题目列表Task Manager Filtering, Deduplication, and Priority Ordering
类型:online_judge
Problem: Implement a Task Manager
You are given a list of tasks. The input order is not guaranteed to be sorted by time. You need to output tasks that satisfy certain conditions, remove duplicates, and sort them by priority.
Each task has the following fields:
id: task ID, string
description: task description, string
due_date: due date in YYYY-MM-DD format
assignee: assignee; - means no assignee
done: completion status, 0 means not done, 1 means done
is_high_priority: priority flag, 0 means normal, 1 means high priority
created_at: creation timestamp in ISO format, for example 2024-01-01T10:00:00
parent_id: parent task ID; - means no parent task
Filtering Rules
Keep only tasks that satisfy both conditions:
No assignee, i.e. assignee == '-'
Not done, i.e. done == 0
Deduplication Rule
If two tasks have the same description and the same due_date, they are considered duplicates. Only keep the first one that appears in the result according to the original input order.
For this version, first apply filtering, then deduplicate the filtered tasks in original input order.
Sorting Rules
Sort the final tasks by:
Earlier due_date first
If due_date is the same, high-priority tasks, is_high_priority == 1, first
If still tied, earlier created_at first
If still tied, preserve original input order
Output Format
For each task, print one line:
Task ID: {id}, Description: {description}
If the task has a parent task, i.e. parent_id != '-', append:
, parent: {parent_task_description}
The parent task description should be looked up from the original input list by parent_id. If the parent task cannot be found, do not append parent information.
Input Format
The first line contains an integer n, the number of tasks.
The next n lines each describe one task, with fields separated by |:
id|description|due_date|assignee|done|is_high_priority|created_at|parent_id
Output Format
Print the filtered, deduplicated tasks in priority order. If there is no task to output, print nothing.
Constraints
0 <= n <= 10^5
id is unique
description length is at most 200
Date and timestamp strings are lexicographically comparable
Example
Input:
5
1|Submit report|2024-05-10|-|0|0|2024-05-01T10:00:00|-
2|Submit report|2024-05-10|-|0|1|2024-05-01T09:00:00|-
3|Fix bug|2024-05-09|-|0|0|2024-05-02T12:00:00|-
4|Write doc|2024-05-09|alice|0|1|2024-05-01T08:00:00|-
5|Review code|2024-05-11|-|1|1|2024-05-01T07:00:00|-
Output:
Task ID: 3, Description: Fix bug
Task ID: 1, Description: Submit report
Example
Input
5
1|Submit report|2024-05-10|-|0|0|2024-05-01T10:00:00|-
2|Submit report|2024-05-10|-|0|1|2024-05-01T09:00:00|-
3|Fix bug|2024-05-09|-|0|0|2024-05-02T12:00:00|-
4|Write doc|2024-05-09|alice|0|1|2024-05-01T08:00:00|-
5|Review code|2024-05-11|-|1|1|2024-05-01T07:00:00|-
Output
Task ID: 3, Description: Fix bug
Task ID: 1, Description: Submit report