NPS-INR-Cyber-Programming-2021

The 2021 edition of the NPS Indiranagar interhouse Cyber Programming contest.

View on GitHub

Jeff Needs Help

Problem Statement:

It is 2090 and Blue Origin’s manned space shuttle beat SpaceX in the race to finding a habitable galaxy. However, the shuttle is running low on fuel. So, the captain, coincidentally named Jeff, has to find the shortest distance to between the shuttle and every other planet. This is what he knows: There are N planets. The shuttle is at Planet Green. There are M safe routes connecting the planets. The ith route goes from city Xi to city Yi and has a length of Zi. Jeff assigns you this task because you are the smartest in the room. He wants a clear symbol, -1 if it is impossible to go to any particular city.

Constraints:

Subtask 1: 10 points

Subtask 2: 20 points

Subtask 3: 20 points

Subtask 4: 30 points

Subtask 5: 20 points

Input Format:

Output Format:

Sample input:

3 3 1 2 3 2 3 1 3 1 1 

Sample output:

2 1