Task Scheduling Validation

Company: Cred_4nov

Difficulty: medium

Problem Statement

Task Scheduling Validation Problem Description A product launch is broken into N tasks, numbered 1 to N , and each task has to be given a start time on a single timeline. The plan also carries M timing rules. A rule A B D means that task B must start exactly D time units after task A starts, that is start[B] = start[A] + D Start times may be any integers, including negative ones, and two tasks may share a start time. Decide whether start times exist that satisfy every rule at once. Input Format Line 1: two integers N and M . The next M lines: three integers A B D , one rule each. Output Format Print Yes if start times satisfying every rule exist, and No otherwise. Examples Example 1 Input: 4 3 1 2 2 2 3 1 1 4 5 Output: Yes Starting task 1 at time 0 forces task 2 to 2 , task 3 to 3 and task 4 to 5 . Nothing conflicts, so the plan is feasible. Example 2 Input: 3 3 1 2 3 2 3 2 1 3 4 Output: No The first two rules put task 3 five units after task 1 , while the third puts it four units afte