CT37796

Ivo and the Wistful routes

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Ivo found an old ledger of routes in the ferry office attic at the salmon ladder of Rushing Falls. The margin notes pose a precise question. 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 <= 2339; 0 <= m <= 4678; self-edges make the answer NO.

Example 1:

Input: 1165 4079 478 769 767 1013 19 668 372 947 360 819 478 947 627 728 347 1059 135 181 545 1127 567 762 342 850 161 341 582 1114 326 545 383 1093 61 248 476 813 584 1044 5 135 726 773 691 1042 512 529 600 604 121 165 127 631 108 386 370 817 430 1003 395 822 351 912 628 731 58 1030 367 474 462 764 441 491 938 1096 1083 1108 194 543 391 1144 371 1099 470 987 892 1065 55 1096 1057 1126 239 640 426 868 503 1033 533 982 411 504 815 1125 24 1119 668 1094 1083 1084 703 888 225 864 876 1104 129 315 341 869 195 1040 525 1043 542 1075 78 1148 379 583 247 920 892 994 759 931 120 823 849 1124 823 1007 345 938 564 1157 724 980 108 194 354 605 672 844 57 728 153 188 452 826 27 896 432 990 395 482 76 1139 611 631 9 872 69 1013 206 605 684 697 958 1030 185 758 340 1028 285 1084 829 1045 872 1035 1019 1048 508…
Output: NO

Example 2:

Input: 406 1642 306 362 70 246 283 330 5 114 33 60 214 383 287 351 210 388 100 389 195 342 239 376 139 191 187 219 171 354 102 231 213 386 55 250 42 265 152 359 72 125 18 61 95 269 3 293 162 197 321 378 159 369 14 382 48 279 267 330 147 195 284 396 161 245 21 335 57 58 98 214 67 219 85 232 164 304 88 273 223 352 246 277 95 244 45 146 288 322 59 310 60 132 236 291 118 227 9 206 157 289 127 283 25 26 61 303 203 249 64 401 246 284 230 246 20 78 161 335 155 217 88 376 1 402 10 277 50 242 65 242 81 331 252 398 81 114 65 106 152 400 80 114 297 396 270 341 40 59 88 317 217 357 64 197 207 288 39 346 144 391 47 206 70 249 3 204 324 406 38 184 2 257 8 217 124 247 213 318 352 405 63 72 289 320 89 305 234 305 187 194 319 403 179 192 52 203 80 253 249 274 344 378 225 350 278 316 140 211 104 206 110 220 76 263…
Output: NO

Example 3:

Input: 811 509 165 346 34 549 409 711 543 703 223 282 48 474 291 386 669 730 167 513 326 373 429 582 78 700 153 706 107 303 186 416 154 503 43 402 48 563 93 413 94 431 338 489 402 584 610 612 24 49 527 596 372 709 574 758 67 312 53 206 88 375 471 531 677 777 286 691 285 558 19 217 681 714 73 723 316 661 346 428 486 725 377 646 353 596 95 606 292 648 605 704 273 341 622 684 262 365 117 794 626 630 492 617 131 654 328 721 355 448 517 586 141 231 553 559 167 797 588 611 302 347 587 757 526 632 301 628 375 673 671 723 316 424 101 562 424 432 642 666 540 776 277 320 612 675 392 403 300 670 53 413 178 476 391 734 427 735 299 582 109 718 102 602 429 786 17 286 421 523 68 535 204 334 93 296 36 810 89 805 303 518 362 423 343 734 22 700 70 300 5 788 250 783 133 486 111 428 271 789 273 553 621 723 38 589 22…
Output: NO

Constraints:

1 <= n <= 2339; 0 <= m <= 4678; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Ivo and the Wistful routes - MEDIUM Coding Problem | CodeTikki