CT32481

Last tunnels of Indu

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the lily shoals of Padmore close for winter, Indu must finish the tunnels ledger - one figure at a time. Task: Print the minimum number of edges on a path from s to t, or -1. Input format: First line: n m s t. Next m lines: u v. Output format: Print the BFS distance or -1. Constraints: 1 <= n <= 536; 0 <= m <= 1072.

Example 1:

Input: 9 36 1 9 1 3 6 7 1 8 2 3 7 9 3 7 8 9 1 7 3 9 4 8 5 7 4 9 1 6 1 9 2 8 1 2 4 6 3 5 2 9 2 6 3 6 1 5 2 4 5 8 3 4 6 8 2 5 1 4 7 8 5 6 4 5 6 9 4 7 5 9 3 8 2 7
Output: 1

Example 2:

Input: 86 112 1 86 39 81 18 71 30 35 8 31 9 57 19 45 51 75 1 54 10 76 1 70 28 86 36 79 31 58 79 85 8 22 24 55 27 71 21 50 16 31 13 41 46 57 64 73 18 69 19 40 10 20 14 33 3 7 21 58 41 44 36 77 32 48 4 48 35 66 24 60 21 23 48 50 35 75 84 86 18 80 12 34 43 72 69 75 5 20 54 68 46 70 17 29 25 50 42 46 16 37 2 30 15 30 36 78 21 55 30 81 28 70 7 35 38 86 35 76 44 49 24 75 18 26 59 73 59 85 18 57 21 49 11 63 25 43 21 35 4 47 73 83 5 18 15 46 4 35 28 76 72 75 14 71 18 77 5 42 48 61 12 84 8 53 65 67 33 35 53 67 56 73 13 14 8 77 6 59 53 55 23 43 4 57 1 67 9 47 41 74 52 79 33 70 56 85 4 82 24 44 20 40 11 73 17 43 15 24 13 75 35 62 44 64 41 70 1 43 32 85 25 63 4 19 11 30
Output: 3

Example 3:

Input: 229 228 1 229 149 205 105 134 99 225 39 83 149 198 39 77 49 95 30 61 75 191 138 200 112 204 13 108 124 210 125 171 103 175 98 184 11 129 20 139 19 96 150 165 125 130 58 64 66 68 165 197 135 157 140 219 102 154 6 166 115 177 17 107 12 136 158 196 9 200 85 149 2 29 62 208 134 223 113 139 137 220 43 72 10 76 96 170 97 188 22 63 29 105 89 123 52 225 129 149 35 200 128 204 121 170 19 50 98 212 112 187 44 229 79 98 98 150 105 138 98 216 93 216 76 168 104 206 150 168 43 138 138 217 42 140 81 92 86 88 21 183 14 122 9 180 14 32 110 163 7 186 38 124 58 117 84 188 117 145 87 102 13 213 72 214 155 161 62 109 13 90 175 215 33 93 6 23 35 82 69 151 31 87 124 209 164 188 34 70 5 182 123 130 115 139 109 126 21 155 54 195 56 195 24 166 61 197 80 158 139 194 78 202 83 152 96 228 15 29 138 143 118 194 12 165 …
Output: 6

Constraints:

1 <= n <= 536; 0 <= m <= 1072.

Loading...
Test Cases:No test cases
No test cases available.
Last tunnels of Indu - MEDIUM Coding Problem | CodeTikki