CT47029

Gardener's corridors Two Guilds

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the singing sands of Echo Dunes, Gardener records each corridors in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3671; 0 <= m <= 7342; self-edges make the answer NO.

Example 1:

Input: 2884 5547 1 2 2 3 1 3 531 1798 1095 2858 789 2619 811 1142 122 501 2349 2597 615 1557 527 1960 16 723 94 185 2231 2484 290 1092 812 2294 408 1741 9 552 1825 2498 592 1547 2134 2715 376 2559 364 1415 529 1662 1463 2503 1381 1753 506 1209 2231 2370 37 1352 89 691 14 848 674 1855 261 1340 12 1908 690 2095 1210 1402 1391 2383 221 2506 1955 2496 2278 2528 149 560 903 1184 212 1237 392 1402 155 2302 1231 1356 517 1184 1203 2112 1871 2487 2132 2248 1188 1539 2296 2667 929 2722 348 613 1470 1727 2551 2831 402 1528 142 711 531 1082 21 2829 1228 2505 613 2243 507 1131 93 337 125 2034 92 2406 2483 2506 1855 1973 525 2186 743 1921 1934 2756 2300 2653 152 2691 1775 2067 835 2331 578 1193 343 364 1346 2133 2792 2797 898 1024 266 2683 1951 2566 1719 2158 936 2785 2000 2198 151 1448 1967 2721 360 2420 222…
Output: NO

Example 2:

Input: 2821 3817 45 1804 1450 2139 1551 2080 656 2763 907 2338 1574 1577 265 1574 1059 1714 1003 1647 321 2068 1054 2251 2037 2381 460 2022 187 1676 1256 2426 2627 2675 924 1769 420 1084 1172 1361 1172 1689 1015 1318 1010 2507 356 485 758 1659 762 2710 1079 2327 274 1054 70 1924 536 1102 642 804 2280 2387 1479 2188 1094 1908 111 401 1300 1898 580 1867 213 730 95 1473 345 2607 521 1375 481 2013 818 2156 1521 1644 693 1702 1088 1402 7 1445 819 1303 1870 2691 574 1181 2094 2533 1255 2740 424 809 1770 2715 311 947 126 824 344 2227 269 2461 854 1847 1824 2689 515 2667 107 1140 910 2789 314 376 653 1300 445 564 1327 2254 1012 2519 87 1142 1724 2440 1495 2339 2016 2250 703 1367 1128 2392 270 982 145 1933 471 742 816 2374 1387 2567 490 1287 2348 2603 94 686 845 2012 1685 2376 1666 2592 1466 2024 482 1533…
Output: NO

Example 3:

Input: 1416 5741 1 2 2 3 1 3 1282 1316 551 1025 73 735 488 721 239 796 424 917 818 1260 254 536 185 329 810 1182 502 1124 661 1096 279 1055 23 633 306 596 111 589 403 713 861 905 497 825 50 1190 461 474 147 365 767 1191 859 1218 360 1015 742 797 104 899 344 928 573 685 295 1382 16 1351 625 741 836 972 130 1368 14 778 593 1201 438 1347 155 250 950 996 496 1361 880 1226 574 1329 897 1013 248 822 160 169 491 907 855 871 70 628 599 1006 217 1134 449 582 670 1292 716 1080 726 1367 892 1099 486 849 363 431 759 814 243 672 566 1117 815 1320 71 518 100 128 55 1310 37 1408 627 822 334 1194 764 1070 514 1151 632 1367 389 865 870 1093 155 1073 723 1116 260 1414 727 1198 71 845 780 1041 205 445 455 1182 220 811 124 428 469 1353 310 509 630 1091 283 1099 266 1086 620 951 1125 1391 1127 1281 346 1240 418 542 2…
Output: NO

Constraints:

1 <= n <= 3671; 0 <= m <= 7342; self-edges make the answer NO.

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