CT47696

Elowen's Wild tunnels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the alabaster quarry of Whitestone with crates of tunnels, and Elowen the inventory keeper must account for every last one. 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 <= 1370; 0 <= m <= 2740; self-edges make the answer NO.

Example 1:

Input: 20 164 7 9 1 5 8 13 4 20 8 12 1 20 3 5 15 16 6 20 4 11 5 8 2 8 5 9 2 20 7 19 12 17 10 18 11 16 11 17 1 15 3 4 17 18 1 3 16 18 13 16 1 6 8 20 17 19 3 10 2 3 10 20 13 14 1 19 1 8 6 8 9 10 5 6 3 20 7 18 13 19 5 20 9 18 2 19 5 14 13 18 11 18 6 9 9 17 13 15 9 20 3 17 16 17 3 12 1 18 18 20 7 8 1 7 15 19 1 10 1 13 1 2 4 17 4 19 5 7 4 12 7 17 10 12 3 8 2 12 10 17 6 16 11 12 1 9 12 15 7 12 12 18 1 11 14 17 2 4 14 15 3 19 3 11 15 17 5 12 12 20 12 19 11 19 3 13 17 20 4 7 2 9 5 10 1 12 2 14 12 16 8 11 7 11 3 16 8 9 8 19 2 11 10 19 10 14 6 13 11 14 7 13 4 10 8 18 1 14 13 20 4 13 1 4 6 15 5 11 11 15 8 16 5 15 11 20 18 19 2 15 2 10 3 18 13 17 3 14 10 11 19 20 6 7 14 16 5 19 11 13 9 11 4 15 10 13 8 17 6 19 5 16 10 16 4 8 7 10 9 16 6 14 9 13 2 18 4 14 15 20 12 13 16 19 2 6 1 17 9 14 5 17 2 5 4 18 7 20 4 6 …
Output: NO

Example 2:

Input: 805 837 1 2 2 3 1 3 714 804 81 461 157 625 167 289 450 544 334 508 10 398 215 716 50 744 518 765 451 798 427 608 585 637 224 505 78 692 455 559 91 753 180 389 369 706 468 616 8 282 29 725 37 550 10 225 95 703 431 668 155 413 141 713 23 705 345 791 462 767 50 704 726 798 375 478 481 514 208 594 428 675 26 406 85 519 154 443 210 800 135 738 276 655 202 294 67 322 468 660 345 379 542 592 137 283 515 743 294 617 66 290 417 480 572 634 18 51 218 793 161 346 467 678 175 644 26 454 49 387 96 502 323 720 394 618 112 347 301 793 115 700 199 283 67 71 465 512 483 677 569 599 2 243 274 446 362 601 96 199 176 524 468 523 77 663 628 662 295 724 202 325 427 474 341 780 28 569 308 551 549 595 276 450 442 778 455 596 21 26 122 450 68 163 168 539 385 416 7 587 166 270 83 555 143 274 358 448 228 400 660 702…
Output: NO

Example 3:

Input: 1060 829 1 2 2 3 1 3 503 1010 422 427 697 791 60 839 276 369 341 1024 84 306 636 708 11 555 88 606 84 284 457 933 352 521 265 291 290 855 206 808 232 510 257 726 360 677 659 808 533 583 415 645 305 586 426 835 21 483 276 828 29 869 7 1026 16 396 18 743 736 927 154 455 86 650 19 245 758 923 346 913 588 962 491 819 132 967 514 1048 289 1041 111 419 423 435 262 962 205 396 420 436 38 789 488 528 80 775 451 612 394 514 195 540 496 883 773 1035 536 847 329 679 139 214 410 707 335 594 370 829 190 633 152 706 594 823 586 1053 352 945 572 591 440 1019 445 718 658 887 383 403 507 744 928 982 547 933 246 808 754 920 149 354 142 368 316 936 665 767 199 892 745 842 180 562 234 697 444 579 274 702 650 660 671 739 49 443 544 758 696 918 697 820 587 1029 67 190 345 1000 54 569 584 1024 391 615 902 1024 2…
Output: NO

Constraints:

1 <= n <= 1370; 0 <= m <= 2740; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Elowen's Wild tunnels - MEDIUM Coding Problem | CodeTikki