CT42336

Zoravar's Wistful routes

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Zoravar the reckoner watches over the wheat plains of Amberfield's stores of routes. A careful computation stands between order and chaos. 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 <= 1636; 0 <= m <= 3272.

Example 1:

Input: 563 2541 1 563 29 150 133 262 87 500 219 320 67 528 52 84 440 452 34 68 287 525 75 502 151 553 271 356 350 420 353 510 477 523 63 470 182 328 406 478 313 513 110 553 129 408 170 271 116 147 149 547 433 531 182 224 106 175 44 429 123 529 421 528 254 351 283 520 25 219 37 442 417 467 385 415 188 248 407 411 238 407 54 80 147 207 9 544 115 201 180 335 318 538 234 502 363 537 85 507 52 414 44 105 141 301 139 444 187 415 452 504 104 208 213 263 76 151 186 521 292 479 270 403 2 411 351 464 207 532 372 485 209 313 114 520 24 388 253 297 131 527 206 250 58 96 195 536 234 505 325 457 215 246 15 531 78 552 3 509 151 442 271 429 17 289 52 398 299 479 83 448 134 187 554 558 52 331 9 33 58 343 286 380 469 563 318 531 58 190 101 257 2 401 301 432 202 272 324 497 143 233 343 383 153 232 312 462 2 364 67 …
Output: 2

Example 2:

Input: 699 1400 1 699 493 595 4 645 4 675 21 231 285 593 208 484 153 446 223 686 391 685 333 532 164 551 373 391 67 658 143 159 198 380 208 681 462 565 345 496 424 563 443 585 208 532 166 494 199 596 171 454 269 682 470 553 511 607 116 375 268 276 25 654 276 462 384 593 632 666 122 341 454 506 82 629 91 167 58 381 69 239 47 147 221 369 467 629 48 460 13 483 310 674 280 351 251 377 188 647 125 362 220 393 109 251 402 519 432 541 444 473 2 473 250 577 233 241 235 447 134 358 7 690 321 641 125 365 101 126 119 199 32 218 213 365 301 639 510 668 410 429 279 580 475 553 388 574 262 368 211 380 346 628 256 519 444 590 470 687 391 494 109 339 636 663 555 647 257 450 2 433 458 661 87 306 48 592 297 681 20 492 139 453 401 681 329 544 54 301 69 187 184 601 363 447 97 411 142 691 76 266 408 675 108 149 157 3…
Output: 6

Example 3:

Input: 1278 1277 1 1278 577 607 534 560 1018 1037 695 899 237 724 293 1239 29 403 710 1241 154 1208 754 924 1153 1270 16 696 380 944 362 365 858 1023 107 690 388 1068 109 1088 46 1111 116 850 577 1092 375 657 377 1020 447 840 216 547 617 1029 261 1189 996 1198 569 847 557 777 159 656 139 1239 1109 1173 343 722 140 474 229 328 75 1002 918 1130 443 759 146 381 461 826 449 453 252 469 291 1176 49 152 13 249 455 879 293 412 309 579 323 539 623 1010 355 997 127 829 293 520 340 1112 15 1040 588 1006 52 1117 73 957 538 1224 1082 1171 948 1189 305 820 11 729 496 1260 423 860 156 943 1213 1273 705 963 136 839 129 756 327 470 395 1214 609 1088 130 827 664 1079 497 590 639 1202 373 647 517 794 791 1266 134 1084 203 1016 220 1039 524 1216 89 208 427 509 782 1275 872 916 300 413 330 549 138 995 123 145 953 12…
Output: 11

Constraints:

1 <= n <= 1636; 0 <= m <= 3272.

Loading...
Test Cases:No test cases
No test cases available.
Zoravar's Wistful routes - MEDIUM Coding Problem | CodeTikki