CT43739

Tarun's Wayward roads

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the cinnabar mines of Vermilion pays by the answer, and Tarun intends to earn it. First: the full register of roads. 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 <= 1733; 0 <= m <= 3466; self-edges make the answer NO.

Example 1:

Input: 1675 1549 1 2 2 3 1 3 1015 1613 448 964 695 1565 509 518 1108 1187 103 212 619 994 756 830 477 712 170 1251 1038 1488 435 711 253 1285 97 757 1164 1455 374 1025 561 1633 831 876 481 1539 889 1354 485 1011 314 1487 31 1233 112 1665 26 28 447 512 875 1578 889 1603 393 1608 45 821 1186 1257 200 559 1271 1610 444 1352 135 1559 641 1651 305 681 56 78 1035 1060 117 254 623 1399 770 959 302 1282 832 1281 765 1578 763 1303 558 1035 52 1032 348 1222 269 1639 592 704 320 1277 695 1180 1113 1376 126 583 315 568 539 978 412 608 485 1032 161 1660 371 1483 585 1624 487 1016 330 1053 72 182 210 1617 466 961 456 656 974 985 590 828 14 890 616 911 121 938 188 460 928 1615 502 676 209 1525 975 1124 668 1452 395 729 1495 1515 825 1247 24 950 694 1591 396 1150 359 1226 11 625 654 1034 218 1469 712 959 666 997…
Output: NO

Example 2:

Input: 1139 2913 18 384 216 894 103 754 477 812 248 1139 100 362 500 1128 28 537 502 661 306 1027 224 300 270 540 654 869 644 754 81 189 218 714 673 798 736 901 752 1126 1105 1133 332 750 216 1057 278 395 623 762 46 378 49 879 639 898 648 724 520 559 293 347 737 858 771 1070 511 877 749 812 19 278 481 999 705 1081 488 818 567 651 614 840 508 867 86 799 210 669 789 975 347 933 368 1072 655 784 114 307 574 742 479 635 619 659 948 1115 1104 1120 206 443 253 685 172 768 29 429 609 853 208 714 690 928 236 311 710 1129 375 617 29 62 197 998 877 991 63 983 10 916 592 801 276 594 686 1043 199 1038 273 854 990 1122 965 973 881 910 257 311 242 637 216 722 647 1065 768 1042 286 585 249 1070 796 1041 515 810 284 297 62 254 135 1011 358 1102 467 478 170 283 521 648 283 353 704 803 334 603 638 768 540 978 10 1…
Output: NO

Example 3:

Input: 1652 22 879 1192 55 1386 401 589 1277 1534 183 475 822 890 1314 1430 22 1496 1002 1490 598 1545 1425 1626 382 1385 1035 1046 911 930 1115 1483 586 1258 1096 1123 397 630 849 1313 141 750 613 1249 772 1163
Output: YES

Constraints:

1 <= n <= 1733; 0 <= m <= 3466; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Tarun's Wayward roads - MEDIUM Coding Problem | CodeTikki