Professional Documents
Culture Documents
problem_statement
problem_statement
Problem Statement
You are given a country represented as a graph where cities are nodes and roads are edges.
There are four types of cities, and you need to find the shortest path from a starting city to an
ending city. The city types and their properties are as follows:
1. Blocked City (B): You cannot pass through or enter these cities.
2. Normal City (N): Regular city with no special properties.
3. Type A Teleporting City (A): Contains a type A teleporting machine.
4. Type Z Teleporting City (Z): Contains a type Z teleporting machine.
Teleportation Rules:
● You can teleport from any type A city to any type Z city and vice versa.
There is exactly one start city (S) and one end city (E), both of which are normal cities.
Input Format
Output Format
● A single integer representing the length of the shortest path from the start city to the end
city, considering the teleportation rules. If no path exists, return -1.
Constraints
5
● 1≤𝑛, 𝑚≤10
Example :
Input:
88
SNANNNZE
12
23
34
45
56
67
78
24
Output:
4