CT50617

Mina's Ledger of bridges

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the eel marshes of Slitherwick, Mina records each bridges in a worn leather ledger. The guild wants answers, not guesses. Task: Print YES if the undirected graph's nodes can be split into two groups with no edge inside a group, otherwise NO. Input format: First line: n and m. Next m lines: u v. Output format: Print YES or NO. Constraints: 1 <= n <= 1453; 0 <= m <= 2906; self-edges make the answer NO.

Example 1:

Input: 788 550 1 2 2 3 1 3 456 647 262 726 144 561 168 380 630 692 340 468 44 123 567 698 178 476 208 402 442 684 141 530 284 571 632 774 170 280 426 686 347 613 22 196 37 530 364 726 71 185 121 326 115 778 378 688 148 197 444 522 160 629 465 509 1 276 332 776 82 695 13 547 195 488 67 171 511 582 305 542 555 758 390 484 415 695 558 620 502 757 235 723 344 562 584 657 1 696 459 734 193 460 199 404 99 536 608 681 122 287 234 249 441 609 362 417 51 779 329 492 586 611 435 656 286 346 7 198 109 218 629 666 226 593 159 577 20 701 76 489 311 658 545 705 67 580 169 206 121 233 544 577 451 568 340 600 359 365 693 701 179 276 243 656 116 403 43 562 55 205 75 226 388 484 77 555 99 455 140 410 476 666 409 479 315 665 3 432 268 416 312 584 200 636 557 691 12 304 184 466 389 691 284 304 422 718 335 368 147 51…
Output: NO

Example 2:

Input: 744 284 139 265 185 505 232 709 641 684 454 470 72 524 88 252 69 356 346 606 207 709 308 473 355 694 160 413 368 647 468 677 341 617 225 583 325 566 460 574 697 727 271 588 291 467 155 425 458 546 610 615 567 741 280 481 96 186 37 436 223 582 91 525 362 391 326 419 469 669 598 628 19 414 90 220 367 627 43 340 484 717 106 182 70 727 520 678 114 137 565 585 324 655 484 561 246 523 79 437 451 556 117 432 33 501 54 422 524 736 415 613 37 388 560 606 662 682 184 454 128 326 348 670 221 348 251 615 211 454 448 595 472 604 80 601 331 546 297 372 399 450 91 211 278 736 61 230 25 112 223 387 4 699 111 197 14 194 44 246 257 363 383 604 502 592 168 679 628 735 255 609 322 531 143 623 462 706 19 644 179 368 23 272 608 690 87 604 385 643 9 161 454 493 40 430 101 546 130 715 203 652 357 596 465 569 271 …
Output: YES

Example 3:

Input: 195 1536 84 136 68 194 16 140 7 124 148 186 7 116 35 74 21 147 18 47 82 174 185 191 98 112 145 158 114 121 164 177 80 180 112 184 151 170 19 42 37 71 130 176 4 33 68 87 110 155 107 173 21 43 23 33 93 183 67 182 45 54 172 177 129 187 144 195 63 76 20 90 33 38 116 171 13 50 57 124 2 82 120 153 50 73 18 99 32 52 24 171 69 88 134 157 42 111 61 139 80 119 111 172 126 168 43 129 104 119 35 95 21 189 45 110 8 35 53 150 92 165 97 146 2 192 55 153 14 53 109 117 9 51 23 189 56 136 29 39 4 182 59 135 118 120 57 156 34 125 97 116 23 88 41 140 68 86 68 98 88 95 1 38 125 132 46 78 23 162 74 105 55 64 175 192 61 90 128 129 44 84 57 119 119 181 186 194 93 109 61 137 155 158 64 101 33 171 12 156 48 51 128 165 32 135 91 134 186 190 7 57 25 53 109 127 46 55 16 42 177 190 168 171 150 176 29 191 65 100 121 155…
Output: NO

Constraints:

1 <= n <= 1453; 0 <= m <= 2906; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Mina's Ledger of bridges - MEDIUM Coding Problem | CodeTikki