CT62431

Manav's Two Guilds Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the pine barrens of Needlepoint, Manav the measurer keeps careful count of the canals. Prepare the guildmaster's brief, every figure matters. 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 <= 2183; 0 <= m <= 4366; self-edges make the answer NO.

Example 1:

Input: 1684 2533 606 1339 29 285 153 1071 856 1049 782 1636 710 1358 42 548 482 1161 965 1318 144 964 808 811 661 1038 1034 1067 187 457 220 261 115 1455 1226 1631 1587 1676 743 973 545 1599 1222 1506 1401 1550 7 630 213 1532 178 206 232 245 950 1445 576 988 924 1047 111 445 180 1419 513 1511 401 1003 993 1000 239 566 1005 1432 383 1375 1465 1485 127 387 191 338 491 1597 623 1536 827 1062 560 865 394 1348 303 485 101 1061 1300 1325 289 921 507 1293 661 1001 186 712 10 191 81 567 1429 1624 332 1187 1601 1618 100 1316 1036 1631 315 463 1079 1426 1134 1143 565 1218 81 1467 391 1352 1395 1479 846 961 80 1186 817 1104 890 1446 661 1273 736 1302 131 1151 412 472 484 1261 753 1033 189 809 267 528 491 640 300 718 859 1045 238 1154 950 1394 447 907 1065 1076 1217 1631 434 1608 84 1384 206 891 92 1064 17 4…
Output: NO

Example 2:

Input: 1268 2457 325 996 237 597 401 997 237 914 159 840 11 1168 622 991 138 1009 355 378 574 746 308 825 680 1261 381 423 191 262 568 669 193 608 519 1168 125 1183 516 636 56 1097 29 193 679 844 156 1150 254 774 632 779 244 598 782 917 10 120 627 807 214 730 370 1248 1164 1180 455 1190 166 1147 98 390 125 663 364 1226 165 203 187 341 779 1059 218 1261 235 1079 301 381 1043 1088 696 734 470 1217 393 928 490 537 294 468 277 717 134 651 815 825 651 766 529 1003 125 609 125 1219 118 452 160 683 725 754 104 806 214 366 471 1254 652 992 125 980 233 348 126 1036 169 786 556 610 781 1234 281 757 354 933 579 696 162 776 964 1094 131 1268 372 918 527 770 776 928 255 1039 648 1249 749 879 231 776 12 872 268 1146 513 874 224 876 362 497 626 736 947 1198 187 240 519 655 707 864 358 907 61 634 389 945 431 936…
Output: NO

Example 3:

Input: 777 2416 1 2 2 3 1 3 437 735 123 313 15 29 80 323 611 759 408 466 179 221 327 482 711 753 66 666 384 733 324 382 443 625 78 717 4 261 155 397 339 775 258 757 236 486 121 142 46 644 100 708 162 185 233 264 497 739 273 523 720 728 2 651 174 233 490 777 328 526 604 624 670 686 71 450 432 591 182 438 42 318 140 424 60 349 16 745 502 565 477 552 13 625 501 599 383 720 239 460 222 232 243 742 548 655 358 565 65 139 46 199 9 183 232 249 338 451 281 355 199 713 46 209 23 764 68 753 558 641 193 453 305 322 424 616 505 741 382 731 122 560 4 202 371 546 141 552 542 650 83 432 226 578 297 712 128 526 176 379 203 455 4 356 204 501 17 748 292 675 426 647 196 255 235 524 488 677 173 765 278 302 37 667 408 765 416 622 314 572 28 719 100 162 736 773 596 771 198 638 145 329 454 525 28 657 221 718 192 261 21…
Output: NO

Constraints:

1 <= n <= 2183; 0 <= m <= 4366; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Manav's Two Guilds Ledger - MEDIUM Coding Problem | CodeTikki