#C3496. Task and Project Status Tracker
Task and Project Status Tracker
Task and Project Status Tracker
You are given a series of operations to update the status of tasks and to query their completion status.
Each operation is one of the following:
C t x
: Change the status of task (or subtask) t to x (where x is 0 for not completed and 1 for completed).Q t
: Query the current status of task t. When t isP
, the query checks whether the entire project is completed, i.e. all tasks (and subtasks) have a status of 1.
If a queried task does not exist in the records, its status is assumed to be 0.
For project queries (Q P
), the answer is 1 only if every recorded task has been set to 1; otherwise, the answer is 0.
Your solution should process the operations and output the result of each query on a new line.
inputFormat
The first line contains an integer n indicating the number of operations.
The following n lines each contain an operation. An operation is either of the form C t x
to change a task's status or Q t
to query a task's status.
outputFormat
For each query operation (Q t
), output one line containing the result. For a query Q P
, output 1 if all tasks are completed; otherwise, output 0.
8
C 1 1
C 2 0
C 3 1
Q 1
Q 2
Q 3
C P 1
Q P
1
0
1
0
</p>