CT40758

Yuri's routes Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The log keeper Yuri has been asked to prepare the winter inventory. On the desk lies a long table of routes readings. 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 <= 1155; 0 <= m <= 2310.

Example 1:

Input: 1014 1571 1 1014 679 1002 196 361 313 759 271 836 178 888 286 429 92 901 674 761 441 702 34 782 317 475 327 561 590 955 564 875 407 676 241 538 175 265 138 208 229 889 394 410 462 844 48 345 657 969 200 547 373 979 15 250 398 501 16 622 138 936 375 705 205 252 238 712 109 813 1 300 51 474 275 434 382 823 252 443 132 193 159 970 4 174 596 605 134 456 479 854 14 568 958 992 243 396 17 850 201 515 651 836 130 351 76 882 138 310 162 339 235 606 203 1012 366 536 623 913 158 907 32 867 509 619 486 921 401 888 395 787 259 497 738 786 579 930 54 921 400 771 206 848 676 851 165 174 14 486 676 951 31 700 753 1006 301 896 408 894 123 707 556 830 401 862 359 890 672 844 81 422 162 358 107 174 574 693 217 727 824 914 236 663 797 904 59 365 641 712 167 501 537 842 12 341 149 464 502 725 500 703 776 945 …
Output: 7

Example 2:

Input: 871 1248 1 871 424 500 198 371 165 738 565 592 374 836 111 643 322 362 347 538 131 433 475 698 308 368 579 847 720 815 445 778 408 444 162 274 567 803 120 783 121 192 359 858 376 604 176 773 416 494 214 495 650 848 96 523 279 629 772 836 442 676 118 777 483 588 273 278 554 865 119 157 131 540 126 329 673 847 628 751 91 542 432 445 792 835 298 528 188 704 161 365 46 476 207 612 38 179 388 549 310 639 381 650 342 424 493 828 322 346 512 592 179 378 95 192 196 699 110 415 265 456 704 739 704 788 219 410 261 676 500 867 7 127 162 230 114 853 86 525 680 709 28 67 97 325 204 525 99 627 33 404 492 730 208 710 143 617 106 427 61 818 99 456 88 344 106 392 419 530 110 816 379 485 239 847 257 483 122 348 153 208 578 632 306 385 279 381 208 637 310 595 129 138 771 865 155 394 458 566 525 711 136 204 3…
Output: 4

Example 3:

Input: 451 2133 1 451 87 201 106 403 218 416 146 167 170 212 58 119 94 260 47 255 27 393 243 450 81 255 9 411 359 372 97 354 166 447 93 318 159 357 52 247 142 403 113 122 317 423 240 388 266 270 182 230 129 375 221 245 1 127 210 305 120 428 153 319 2 243 136 233 64 421 49 283 218 370 262 279 138 252 214 219 212 293 65 133 9 412 153 181 14 229 315 419 387 398 279 334 16 314 157 370 81 359 114 258 69 165 66 369 214 427 16 408 253 378 120 335 148 386 57 282 233 341 15 243 388 427 15 38 19 285 88 313 148 339 341 409 376 395 101 213 234 375 29 370 74 82 165 332 6 246 120 148 275 415 124 428 190 335 57 138 338 376 185 186 213 326 239 309 311 374 302 355 166 378 142 424 87 254 42 241 193 219 28 43 59 168 290 296 129 230 140 354 92 348 374 422 84 302 231 386 169 356 53 200 2 330 197 295 225 368 10 233 13…
Output: 3

Constraints:

1 <= n <= 1155; 0 <= m <= 2310.

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