#K86467. Project Task Completion
Project Task Completion
Project Task Completion
You are given a list of tasks. Each task has a unique name, a status, and a list of dependencies. The status is either complete
or incomplete
. A task depends on other tasks and can only be executed after all tasks it depends on have been executed. The project is considered complete if and only if every task can be executed in an order consistent with its dependencies and every task is executed successfully.
In other words, if we denote by \(T\) the set of tasks and for each task \(t\) let \(D(t)\) be its dependency set, then the project is complete if there exists an ordering \(t_1, t_2, \ldots, t_n\) of the tasks such that for every task \(t_i\), all tasks in \(D(t_i)\) appear before \(t_i\) in the ordering, and, importantly, a task is only considered executed if it is either originally marked complete
or it can be executed (i.e. scheduled) in this ordering. Note however that for this problem, only tasks that are initially marked as complete
are treated as executed. Thus, if any task is marked incomplete
, even if its dependencies allow it to be executed, the project cannot be considered complete.
Your task is to determine whether the project is complete. Use the following input and output format for your solution.
inputFormat
The first line contains an integer N
representing the number of tasks.
Each of the following N
lines describes a task in the following format:
name status D dep1 dep2 ... depD
Here, name
is a string (without spaces) representing the task's name, status
is either complete
or incomplete
, D
is an integer indicating the number of dependencies, followed by D
dependency names. If D
is 0, the dependency list is empty.
outputFormat
Output a single line: True
if the project is complete, and False
otherwise.
2
task1 complete 0
task2 complete 1 task1
True
</p>