CT52520

Lakshya's Granite Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the frontier camp of Duskwood, Lakshya the registry keeper keeps careful count of the canals. Track down a clerical error, 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 <= 2141; 0 <= m <= 4282; self-edges make the answer NO.

Example 1:

Input: 1110 3800 1 2 2 3 1 3 294 981 302 853 33 802 47 388 37 1107 282 343 129 690 114 140 900 980 269 405 215 1059 59 423 227 384 1020 1081 151 1027 682 867 231 906 183 279 120 812 65 539 475 825 212 545 45 173 457 981 764 947 668 1078 402 765 818 828 237 849 473 744 82 292 97 160 405 575 176 528 528 937 524 822 663 823 148 269 488 693 187 391 108 472 344 650 663 675 365 875 31 317 806 1010 880 1042 707 978 37 189 51 437 18 200 217 718 58 798 586 780 652 784 683 907 777 884 724 799 447 722 144 762 558 756 231 1104 833 990 279 999 252 340 826 1004 973 1096 446 496 755 1062 527 720 148 1025 240 755 288 837 559 960 370 1046 465 1089 17 92 132 989 212 465 335 690 188 405 891 953 11 784 267 309 317 419 467 1024 727 1038 259 368 672 875 306 494 380 919 351 727 127 686 852 960 368 379 269 715 220 774 4…
Output: NO

Example 2:

Input: 240 3139 139 142 36 237 49 60 139 209 195 222 43 99 190 198 58 164 193 211 154 166 60 89 59 134 190 230 16 153 98 194 27 32 18 228 67 151 55 200 8 139 88 227 28 160 54 184 13 16 15 47 8 193 71 176 42 192 121 140 138 237 87 182 52 201 141 161 55 222 3 55 70 126 96 123 201 234 74 146 142 205 191 195 154 192 76 203 22 204 115 212 151 234 140 141 96 203 166 199 31 50 61 181 2 138 15 27 152 166 16 35 96 122 127 229 94 236 68 168 30 75 25 30 11 85 189 216 21 60 68 152 54 81 40 81 222 231 89 219 37 145 13 124 200 205 80 108 31 42 126 197 86 176 55 220 24 198 73 113 36 124 145 223 16 181 18 114 205 221 66 139 151 160 83 161 58 142 188 201 162 236 64 149 152 201 27 117 172 228 133 219 10 164 4 20 14 119 19 174 148 158 213 237 51 55 6 230 209 211 37 107 12 109 119 155 67 227 85 145 44 135 41 207 110…
Output: NO

Example 3:

Input: 2127 2826 663 729 269 847 240 1097 292 819 90 243 400 1940 549 567 618 799 506 535 201 1241 942 2090 650 1207 447 615 884 1318 1800 1866 1243 2002 1652 1876 881 1026 508 740 868 1183 18 1360 117 1929 293 2036 805 936 310 550 1593 1668 724 1004 838 1860 1121 1165 106 316 891 1036 74 234 607 1679 302 1966 385 1286 559 678 1455 2111 1147 1162 707 763 2074 2084 406 1711 1112 1909 62 1689 1028 1971 1078 1370 261 1398 398 1797 1722 2035 1181 1652 121 799 381 1096 330 1959 123 1592 145 1621 274 807 143 1702 617 1130 476 1362 38 1085 1702 2018 576 1563 1158 1841 939 1352 32 1572 250 1038 71 1613 762 2028 28 1100 886 1933 651 1476 654 2035 1166 1575 1499 1953 958 1760 1057 1262 469 1119 795 1486 439 1264 12 328 48 1331 672 735 269 308 1211 1847 1462 2019 169 491 137 1582 270 1345 37 723 283 395 122…
Output: NO

Constraints:

1 <= n <= 2141; 0 <= m <= 4282; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Lakshya's Granite Ledger - MEDIUM Coding Problem | CodeTikki