← 返回 rippling 的题目列表Filter and Sort Task Scheduler
类型:online_judge
Problem: Filter and Sort Task Scheduler
You are given a list of tasks. Each task has:
id: unique task ID
due_date: due date in YYYY-MM-DD format
create_time: creation timestamp, for example 2024-01-01T09:00:00
is_high_priority: 1 for high priority, 0 otherwise
assignee: assignee name; - means unassigned
completed: 1 if completed, 0 otherwise
parent_description: description of its parent task; - means no parent
Return the list of tasks that should run now.
Filtering rules:
Exclude tasks that already have an assignee, i.e. assignee != "-".
Exclude completed tasks, i.e. completed == 1.
Sorting rules:
Earlier due_date first.
If tied, high-priority tasks first.
If still tied, earlier create_time first.
If still tied, sort by id lexicographically for deterministic output.
Output rules:
Print one task per line.
If there is no parent description, print id.
If there is a parent description, print id parent=parent_description.
If no task should run, print EMPTY.
Input Format
The first line contains an integer n.
The next n lines are pipe-separated:
id|due_date|create_time|is_high_priority|assignee|completed|parent_description
Constraints
0 <= n <= 200000
id is unique
due_date and create_time can be compared lexicographically
Example
Input:
5
T1|2024-06-10|2024-06-01T09:00:00|0|-|0|-
T2|2024-06-05|2024-06-01T10:00:00|0|-|0|ParentA
T3|2024-06-05|2024-06-01T08:00:00|1|-|0|-
T4|2024-06-05|2024-06-01T07:00:00|1|alice|0|-
T5|2024-06-01|2024-06-01T07:00:00|1|-|1|-
Output:
T3
T2 parent=ParentA
T1
Example
Input
5
T1|2024-06-10|2024-06-01T09:00:00|0|-|0|-
T2|2024-06-05|2024-06-01T10:00:00|0|-|0|ParentA
T3|2024-06-05|2024-06-01T08:00:00|1|-|0|-
T4|2024-06-05|2024-06-01T07:00:00|1|alice|0|-
T5|2024-06-01|2024-06-01T07:00:00|1|-|1|-
Output
T3
T2 parent=ParentA
T1