CT58849

Asha Counts the canals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The scribe Asha has been asked to inspect the delivered goods. On the desk lies a long table of canals readings. 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 <= 1974; 0 <= m <= 3948; self-edges make the answer NO.

Example 1:

Input: 887 3946 21 388 291 855 307 472 24 741 64 599 585 622 89 275 349 456 412 871 83 263 76 764 76 149 684 803 3 739 15 799 440 717 79 504 356 544 47 474 41 671 314 740 309 644 262 611 741 762 112 766 6 407 7 305 25 35 550 567 179 864 103 296 65 562 61 105 615 836 265 640 696 715 73 832 480 549 693 820 42 750 477 601 128 491 134 449 111 857 52 723 265 518 203 531 129 325 35 582 251 435 686 773 507 760 9 693 260 618 223 577 74 728 78 163 304 536 493 741 54 168 119 810 435 730 487 697 495 747 459 543 261 367 228 863 157 300 377 560 478 605 195 543 344 610 379 452 243 454 334 457 363 473 183 642 177 682 377 537 368 840 123 344 47 682 162 626 239 643 138 699 360 465 113 686 856 868 552 610 172 328 198 473 191 443 42 506 397 854 617 883 555 820 342 607 356 698 575 749 2 341 341 444 10 638 137 804 19…
Output: NO

Example 2:

Input: 784 3523 534 584 343 509 217 487 299 761 174 680 411 518 19 252 653 737 368 457 7 656 74 556 252 489 70 252 44 774 474 681 270 576 166 625 318 442 94 227 12 176 212 504 297 552 598 739 67 740 162 688 252 667 298 429 312 548 36 704 372 611 231 475 196 330 110 719 246 429 565 692 123 550 18 454 433 575 280 482 173 584 48 178 153 563 51 574 232 535 510 634 179 310 304 628 4 544 519 592 51 283 183 200 140 487 98 415 242 321 202 750 19 227 79 337 175 750 129 712 282 362 9 184 154 692 126 737 64 151 429 512 89 533 159 178 301 409 428 509 491 500 215 750 426 491 30 95 65 767 219 290 205 279 544 547 104 415 575 641 87 614 93 657 162 176 228 365 566 759 487 650 138 529 10 687 211 628 101 528 277 460 77 199 737 747 328 762 110 703 521 691 316 380 264 448 378 615 467 601 5 474 337 722 203 244 97 435 …
Output: NO

Example 3:

Input: 1559 1371 181 663 5 1520 299 820 509 1089 805 1278 82 173 622 794 1442 1498 616 1051 181 710 338 747 765 1181 1009 1091 565 643 16 774 283 296 503 1380 58 1328 342 1251 376 1096 1124 1266 440 578 1132 1298 329 736 509 1419 753 999 1182 1228 1278 1319 99 356 397 1139 330 1543 354 1453 199 1479 1355 1357 673 1441 515 995 149 563 536 884 332 729 348 1057 745 1484 1047 1182 229 876 520 1268 401 1393 465 1234 50 1274 517 874 51 1086 30 894 701 1155 182 1067 61 963 548 620 1021 1451 135 1495 340 1078 606 1559 652 1322 232 1523 902 1286 113 1454 1052 1559 107 1073 198 1403 501 537 428 1480 47 641 1451 1527 706 1248 720 1174 315 660 62 1083 59 73 139 1348 67 973 469 1226 196 459 1215 1408 21 1055 314 380 415 505 1037 1112 1138 1461 167 440 713 1448 5 1367 332 1512 796 1038 260 873 525 1286 1068 12…
Output: NO

Constraints:

1 <= n <= 1974; 0 <= m <= 3948; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Asha Counts the canals - MEDIUM Coding Problem | CodeTikki