CT62734

The Silkmead Two Guilds

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the mulberry rows of Silkmead. Kabir spreads the roads records across the table and picks up a sharp pencil. 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 <= 2990; 0 <= m <= 5980; self-edges make the answer NO.

Example 1:

Input: 2392 4866 1 2 2 3 1 3 1214 2165 467 1247 1337 1879 25 2341 1143 2288 235 925 661 2353 1730 2370 464 1910 1108 2308 388 1005 328 1429 174 466 89 219 841 1163 1199 1393 259 2120 1037 2029 193 560 1780 2329 1707 2273 1042 1891 1197 1922 965 1790 198 1729 178 736 560 661 1078 1920 1720 1873 812 1387 802 1412 176 1061 1914 2285 428 1640 1420 1436 689 1244 106 1248 1013 1906 1360 1365 561 2066 1596 1832 2038 2219 1541 1902 689 2132 1233 1896 350 1031 271 1115 327 422 444 895 608 2219 757 1475 9 158 468 644 1018 2375 1919 2322 286 1454 1618 2189 408 1126 132 1504 1128 1701 433 2023 1086 2277 1758 1990 749 1656 114 413 1247 1488 1360 1370 214 342 1178 1843 732 2271 32 1827 1994 2338 1889 2360 151 1814 717 1215 1016 1357 1803 2224 562 2034 1028 1306 332 543 689 696 456 2199 120 2217 1515 2343 1525 …
Output: NO

Example 2:

Input: 1897 2503 308 623 335 629 954 1803 434 1623 103 1793 628 1582 1250 1429 1666 1755 219 362 756 1322 98 623 475 1059 603 1808 546 1532 377 439 1320 1785 91 1811 179 659 1530 1690 397 1111 68 1652 566 675 364 1784 661 1313 27 1555 457 1047 571 1353 438 1855 238 1117 395 727 246 1573 293 1218 1060 1119 211 569 725 804 339 886 733 1115 1167 1679 154 738 78 697 779 1433 1271 1590 959 1225 927 1255 313 1793 259 1111 252 804 350 407 1151 1549 720 1263 363 1420 53 1368 404 1745 1118 1834 46 1610 951 1474 1014 1802 1021 1711 1627 1725 241 1893 621 1471 285 1115 1558 1754 749 902 521 1414 93 1714 260 565 1805 1846 1142 1892 983 1822 985 1895 930 1475 217 283 161 269 1759 1833 245 934 541 1625 347 1592 742 1464 704 866 1069 1803 393 1027 156 1198 253 686 994 1439 529 1470 469 682 589 1777 791 1262 799…
Output: NO

Example 3:

Input: 1385 2419 1 2 2 3 1 3 166 177 552 881 877 1063 624 842 628 1174 511 643 477 858 75 1099 183 469 481 1312 47 399 626 1164 118 652 359 1155 182 998 493 821 627 919 575 736 2 28 510 985 406 716 111 437 921 1274 765 1024 219 1017 268 1358 962 1305 313 874 168 1074 107 1296 874 907 294 739 671 968 431 759 653 735 210 328 475 548 161 968 288 327 1085 1260 526 1325 3 411 496 938 578 1218 440 1241 756 1044 1114 1146 508 1215 608 860 467 1326 195 1237 82 945 557 1355 657 1290 330 1370 252 869 1026 1052 172 1169 801 815 246 1157 827 968 106 1336 701 1082 697 1321 334 971 573 656 435 1278 317 1229 1089 1222 829 1119 16 645 350 420 51 429 1269 1312 421 548 202 260 766 809 981 1063 370 668 253 591 23 482 215 756 228 408 212 875 277 1131 692 1292 788 1130 273 913 181 733 1304 1382 31 314 62 377 629 967 …
Output: NO

Constraints:

1 <= n <= 2990; 0 <= m <= 5980; self-edges make the answer NO.

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