CT58818

Last roads of Wren

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Wren inherited the gallery at the lotus ponds of Tranquil Basin along with its curious bookkeeping system for roads. Time to make sense of it. 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 <= 1288; 0 <= m <= 2576; self-edges make the answer NO.

Example 1:

Input: 647 1511 72 128 224 260 239 546 73 161 243 262 329 468 169 180 491 643 2 66 53 501 273 627 79 320 349 545 158 552 202 591 176 284 137 233 397 598 627 645 218 446 515 564 140 253 135 527 547 583 363 610 252 460 181 503 60 383 58 631 184 564 381 584 278 579 135 476 256 477 274 287 18 142 229 575 327 342 297 390 245 521 155 516 262 484 147 441 104 458 108 405 562 591 426 635 73 345 372 456 263 530 84 363 152 622 276 549 266 581 475 631 242 300 346 442 148 236 22 619 120 442 173 199 122 261 447 500 144 232 11 557 268 514 267 389 529 550 327 364 27 611 154 645 439 570 347 433 156 489 177 229 285 347 22 154 484 607 221 450 280 403 189 407 53 576 2 608 227 577 157 392 182 209 38 87 307 466 392 417 210 645 133 321 580 619 311 502 244 320 422 615 180 212 341 466 54 564 243 525 162 164 83 382 360 36…
Output: NO

Example 2:

Input: 915 2497 302 366 190 222 481 755 608 641 769 906 143 647 1 837 468 524 474 747 22 649 290 303 297 729 145 518 61 79 784 835 218 568 91 700 510 699 91 395 166 572 602 776 233 613 8 585 64 888 222 668 300 796 38 837 397 622 407 425 237 903 74 716 606 768 536 670 271 802 584 637 145 913 332 518 26 524 67 897 182 560 609 645 88 561 19 455 139 366 295 378 148 438 59 88 484 758 148 888 630 868 143 155 450 582 61 495 605 719 368 668 329 430 476 770 684 801 77 296 451 663 264 504 196 597 269 666 325 625 443 544 147 407 174 650 537 598 69 459 247 517 272 353 24 662 205 817 456 548 103 751 224 419 134 666 718 875 150 541 197 239 454 692 173 375 35 79 224 413 561 625 154 391 269 600 194 221 103 878 111 553 182 775 350 484 21 95 162 510 199 439 518 833 323 591 138 316 559 865 289 459 224 539 154 825 6…
Output: NO

Example 3:

Input: 887 381 1 2 2 3 1 3 55 734 395 765 200 883 739 743 410 799 432 710 29 444 831 870 672 702 770 797 429 544 775 812 300 828 147 673 440 642 204 224 315 532 161 759 175 321 97 822 684 829 367 717 153 377 411 623 98 155 169 584 702 811 551 756 6 323 402 669 574 728 538 873 223 847 614 760 418 631 526 838 80 715 250 258 330 841 311 792 221 505 39 844 795 859 197 768 235 279 213 638 251 489 204 401 541 862 338 436 809 856 298 334 222 405 268 439 335 783 172 222 438 454 83 847 270 291 722 771 562 646 258 726 502 704 30 427 750 779 200 360 582 593 672 772 9 706 144 201 161 571 308 842 263 403 120 837 445 616 546 786 124 597 364 867 193 548 136 765 546 850 198 334 84 682 280 781 236 607 238 363 331 593 353 700 763 883 228 347 66 726 58 363 160 745 696 791 83 255 85 326 23 419 437 783 537 696 5 686 …
Output: NO

Constraints:

1 <= n <= 1288; 0 <= m <= 2576; self-edges make the answer NO.

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