Task 3 - Maeglad/TEA-class GitHub Wiki

In the city we have n crossroads and between some of them are undirected roads. (imagine graph here)

About each road we know how long it is and whether it is safe or not. Our mission is to find if there is path from point a to b minimizing time spent on dangerous road firstly and secondly minimizing time spent on roads in general.

Input:
In first line we have three integers N R Q <- number of crossroads, number of roads, number of queries.

R lines follow each containing 3 integers and one character: x y C S <- x, y denotes crossroad id, C is cost of path between x and y, S is either 'B'(safe) or 'N'(unsafe)

Q lines follow each containing 2 integers: x y denoting query for path between x and y

Output:
For each query output two numbers: time spent on dangerous roads and total time spent on roads, if there is no path between x and y output -1 -1

sample in/out:

4 2 3
0 1 30 N
2 1 30 B
0 1
0 2
0 3

30 30
30 60
-1 -1

⚠️ **GitHub.com Fallback** ⚠️