CT37197

The Two Guilds of Tidewater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The ledger master Jatin has been asked to document the rare sighting. 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 <= 2417; 0 <= m <= 4834; self-edges make the answer NO.

Example 1:

Input: 2130 4201 112 968 171 1030 1353 1954 182 429 306 1267 1006 1138 326 779 261 1481 174 2115 848 888 1096 1412 594 1395 1011 1606 475 1167 190 2005 278 646 36 1350 1123 2099 286 1191 601 1367 436 1621 167 753 17 1695 475 504 637 1610 203 1264 1119 1311 163 1325 458 2060 308 1790 99 1698 575 771 49 1724 1151 1286 186 378 1419 1900 50 770 353 360 1807 2062 827 1695 226 1096 705 1872 1617 1619 794 1073 1612 2093 1525 1722 752 846 253 1996 70 296 431 1078 642 1400 80 345 209 604 1077 2060 903 1993 457 1498 222 1395 126 663 1651 2000 1386 1518 1417 1564 1647 1652 1408 1747 610 1389 1464 1844 450 1950 699 1112 339 1753 1537 1799 720 1945 1779 1859 521 706 45 2122 849 1408 1535 1683 377 1562 643 1319 62 1847 795 876 741 814 60 172 768 1438 218 545 120 1153 1663 1909 984 1489 813 1071 168 1665 739 16…
Output: NO

Example 2:

Input: 1560 4528 1 2 2 3 1 3 784 1533 1024 1136 782 892 43 284 373 847 1049 1475 406 499 580 1290 35 44 400 1327 1164 1376 193 862 439 460 17 615 40 1144 378 863 1014 1026 891 1304 1075 1329 1274 1384 1220 1454 90 657 1059 1541 566 885 710 1235 1066 1194 438 552 956 1461 470 1332 906 1312 388 1209 624 712 780 1430 236 792 1205 1299 42 839 188 1185 835 970 726 1526 430 540 255 742 27 700 235 514 525 1307 936 977 10 261 428 1207 2 646 499 1560 25 1032 76 367 397 584 965 1256 207 393 576 1434 181 473 65 1203 292 1334 70 843 50 1068 324 482 266 695 1055 1279 13 310 482 1463 282 990 457 1007 94 1020 36 502 134 1496 448 1492 1089 1208 334 1125 771 945 628 1535 416 1030 377 471 1147 1388 502 1456 21 75 675 1227 407 890 343 948 494 999 204 590 941 1549 171 765 336 1122 328 447 800 1118 330 875 786 829 11…
Output: NO

Example 3:

Input: 1798 4691 551 1194 1559 1579 158 1743 681 1525 1022 1619 186 1353 174 1398 1674 1681 668 948 545 731 685 1533 703 1011 1429 1665 196 1329 864 1276 512 760 517 1265 627 1588 66 1673 875 1218 48 339 165 543 1201 1305 470 659 453 1093 288 955 641 1711 15 1643 64 270 1339 1479 221 654 860 1294 491 1115 988 1314 593 1210 885 1247 886 963 825 1441 296 529 557 1204 1047 1753 263 597 183 1037 154 1257 324 1510 567 1590 51 1254 871 1349 1341 1761 203 1491 103 147 671 1116 1547 1688 381 871 359 860 739 1603 1089 1132 795 1706 571 794 810 1653 977 1402 644 903 978 1158 276 1635 145 519 471 1762 597 1485 1359 1450 641 1710 622 1181 373 900 1670 1680 607 1130 468 496 192 1755 697 1776 660 1369 1056 1059 434 863 189 310 936 1279 41 375 863 902 200 722 1055 1785 425 1656 300 1010 570 1756 262 709 318 435…
Output: NO

Constraints:

1 <= n <= 2417; 0 <= m <= 4834; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The Two Guilds of Tidewater - MEDIUM Coding Problem | CodeTikki