CT50801

Axel's roads Two Guilds

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the anvil district of Hammerfall; Axel weighs the day's roads manifests and starts the calculations. 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 <= 1602; 0 <= m <= 3204; self-edges make the answer NO.

Example 1:

Input: 1231 2607 1 2 2 3 1 3 31 974 1197 1227 425 1114 662 1134 212 296 945 1088 138 1221 61 631 157 1181 506 652 184 842 828 958 984 1007 121 1012 277 725 573 1041 762 1228 310 907 677 693 211 1088 736 1227 53 288 1082 1203 115 875 271 1090 185 960 956 1024 269 990 436 504 537 768 240 959 126 879 377 416 540 1113 213 738 552 662 237 508 615 981 598 1005 581 634 782 874 182 763 241 822 677 969 955 1205 126 913 38 645 1031 1155 540 783 260 801 427 520 892 901 61 1092 1016 1144 171 564 692 956 887 1087 246 458 22 321 577 1038 765 901 828 945 458 830 26 355 307 549 150 273 122 638 104 404 601 745 246 1066 245 798 288 340 318 892 411 571 313 1112 264 625 564 1034 216 374 666 894 722 1230 102 379 302 1010 114 645 260 507 31 168 177 883 118 731 18 595 926 1167 715 776 442 1229 391 918 534 942 573 686 8…
Output: NO

Example 2:

Input: 1502 500 909 1054 344 1095 165 439 14 367 638 1400 787 1500 322 1055 278 1007 548 987 85 787 503 513 362 1009 1344 1425 175 291 119 701 591 1500 232 825 159 740 125 861 1072 1116 221 1469 149 794 590 1098 698 1128 573 1474 597 1458 41 85 1449 1502 881 1135 522 1232 961 1400 963 1205 233 861 834 1067 70 1402 551 711 188 390 11 803 518 733 706 823 829 1311 336 444 393 686 246 353 500 604 1295 1462 757 810 337 1262 474 714 557 1359 41 496 566 1134 230 789 634 906 821 1461 598 1480 956 1401 432 972 229 1368 285 548 1269 1340 681 861 572 1038 606 767 396 585 961 1039 829 1501 29 633 616 1364 288 1342 295 705 155 1278 1235 1282 794 1289 917 1047 744 884 99 1370 507 1201 808 816 622 788 199 1031 77 1230 259 349 357 1198 933 1346 1244 1384 448 631 327 670 109 707 189 864 156 1083 401 1411 944 1397…
Output: YES

Example 3:

Input: 386 1970 1 2 2 3 1 3 286 339 91 172 106 292 21 382 324 364 182 215 80 290 6 77 134 285 170 356 217 253 248 268 160 372 56 60 60 164 81 206 68 132 156 296 29 302 226 266 61 159 40 160 171 217 41 246 17 313 82 137 61 200 314 330 165 264 3 60 33 384 156 251 241 327 68 240 6 248 18 265 137 336 136 293 122 351 27 229 37 164 131 253 55 66 252 266 59 198 64 367 338 365 65 230 185 191 80 379 19 343 84 169 31 280 82 211 163 215 9 261 165 183 30 173 24 116 48 55 11 118 76 149 54 256 253 356 164 333 106 224 128 376 63 130 145 195 137 324 15 204 71 191 37 81 6 46 66 283 251 294 316 351 8 290 68 292 128 362 59 358 62 339 101 263 47 154 103 385 92 127 178 295 125 126 304 383 2 114 105 133 196 280 268 330 65 295 62 167 126 295 49 238 44 333 99 303 133 210 55 100 155 276 164 254 341 359 68 299 169 203 264…
Output: NO

Constraints:

1 <= n <= 1602; 0 <= m <= 3204; self-edges make the answer NO.

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