CT62450

Iker's Two Guilds Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The cartographer Iker has been asked to plan the festival budget. On the desk lies a long table of corridors 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 <= 2514; 0 <= m <= 5028; self-edges make the answer NO.

Example 1:

Input: 271 2073 14 195 93 95 68 94 54 120 100 127 44 174 58 122 85 108 111 241 99 260 110 116 181 261 79 83 25 225 153 168 176 187 104 268 25 76 82 187 167 195 42 250 4 271 149 220 110 247 42 67 129 168 250 269 20 96 5 61 78 139 70 124 40 238 115 189 1 11 11 154 35 60 121 206 76 197 150 254 41 201 206 241 118 187 30 35 39 95 188 247 3 242 125 216 5 217 124 169 10 77 163 177 13 66 130 198 143 150 63 205 90 249 152 226 229 246 37 222 115 121 19 253 99 226 40 126 66 164 156 174 58 72 12 63 25 69 151 260 72 217 23 89 48 266 89 236 12 189 70 143 11 200 42 49 151 195 29 250 161 239 52 66 74 93 53 88 58 243 66 89 58 247 229 239 126 226 43 185 80 128 186 222 30 48 182 239 60 240 50 189 75 174 36 259 160 202 113 116 56 204 68 207 161 215 225 259 75 168 187 189 149 269 90 215 22 55 157 233 75 144 21 252 30…
Output: NO

Example 2:

Input: 2462 2275 892 2042 691 1816 37 1576 814 1707 511 917 1987 2414 51 1459 1420 1601 21 1460 275 2119 223 1881 122 1081 1058 1086 1532 2020 1446 2430 238 1514 88 1905 816 1703 997 1364 950 2040 1640 1978 674 1308 564 2435 892 1488 285 1453 1202 1558 628 680 1634 1913 713 1994 1722 2027 1201 1507 615 1930 349 2284 551 2219 205 1021 512 1390 611 809 67 980 2228 2313 1025 2064 869 1188 2196 2336 2077 2350 1837 2222 1874 2390 1264 1484 1204 1415 34 1538 1502 1603 1012 1808 703 1918 625 985 254 554 9 1246 819 1418 1105 1234 1401 1447 1330 1525 113 1864 811 2176 884 1636 838 886 1615 1665 33 1571 1078 1663 1273 1778 971 1864 1275 1712 675 1916 299 1704 1222 2327 806 2277 1964 2004 904 1370 794 860 2001 2215 533 1854 24 1996 806 1887 46 1715 602 1943 277 2292 1545 2374 65 2388 634 988 1761 2206 419 5…
Output: NO

Example 3:

Input: 1148 2639 406 465 647 1040 427 1064 742 932 64 312 221 1007 109 775 632 949 375 1055 18 147 98 464 255 269 229 615 306 1023 97 587 822 1080 352 729 117 521 197 980 43 795 404 543 551 964 306 818 218 780 655 724 194 479 316 797 557 891 384 789 1049 1133 553 571 920 1085 182 514 796 947 211 912 684 1043 107 420 657 927 321 372 753 756 556 1017 329 658 843 965 51 1043 563 767 152 181 313 314 634 638 924 1044 513 838 73 310 60 256 293 803 88 920 335 669 332 719 26 882 416 706 1009 1037 299 392 293 881 1066 1143 676 1011 121 859 80 438 337 905 538 833 385 1042 210 225 40 366 656 687 761 984 623 830 14 341 685 710 191 651 397 1089 168 1090 30 153 99 349 795 803 382 913 600 949 810 1050 871 930 388 635 48 684 76 564 244 1142 373 557 307 360 441 889 93 290 182 609 56 725 88 532 218 566 614 653 499…
Output: NO

Constraints:

1 <= n <= 2514; 0 <= m <= 5028; self-edges make the answer NO.

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