CT60819

Last bridges of Elowen

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the granite steps of Stonehallow with crates of bridges, and Elowen the cartographer must account for every last one. 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 <= 2775; 0 <= m <= 5550; self-edges make the answer NO.

Example 1:

Input: 571 159 1 2 2 3 1 3 247 343 330 458 281 428 72 254 44 488 48 498 93 256 77 91 318 546 411 461 98 385 262 337 45 266 76 80 262 419 433 481 99 167 133 473 276 565 13 425 215 323 265 375 224 440 40 327 3 202 278 564 106 298 265 400 316 520 91 246 182 267 181 259 202 272 144 528 6 151 230 442 317 479 507 570 331 438 175 413 166 518 200 405 180 334 11 486 7 188 84 170 19 467 137 191 74 482 21 46 89 387 199 226 383 567 135 292 260 451 373 403 42 297 143 199 422 430 117 447 3 508 111 158 356 461 221 329 298 550 187 236 44 90 118 513 174 519 243 519 117 272 256 486 475 560 275 376 77 268 121 555 246 389 54 83 209 291 107 442 119 252 163 241 264 433 308 410 132 570 107 190 72 224 450 461 7 330 205 435 46 380 288 545 212 315 137 212 253 418 86 394 18 551 459 530 63 383 21 94 181 488 10 482 49 70 199…
Output: NO

Example 2:

Input: 686 4524 1 2 2 3 1 3 272 295 554 671 105 291 46 604 387 674 220 589 211 646 125 302 70 504 57 151 274 446 539 597 58 549 141 237 419 501 306 507 350 576 2 324 629 673 512 553 364 666 144 280 218 240 108 563 97 220 1 515 97 585 372 550 81 95 84 631 406 503 146 484 103 427 294 327 436 650 206 278 134 421 94 432 224 620 224 317 270 451 223 476 379 416 132 670 161 604 227 268 219 617 576 632 200 594 358 532 129 566 257 558 351 682 73 460 479 670 137 308 205 227 80 530 43 180 48 217 331 471 257 328 390 461 111 656 181 490 205 360 21 443 344 435 279 602 313 612 221 260 172 513 504 574 197 200 360 517 262 515 70 187 391 540 251 540 101 121 171 286 313 569 184 343 95 172 371 686 147 538 362 406 364 578 374 659 62 169 31 269 390 437 286 503 256 368 66 259 175 517 35 195 205 324 25 32 100 272 225 48…
Output: NO

Example 3:

Input: 2390 212 1 2 2 3 1 3 65 376 114 791 1114 1248 1276 2148 1538 2132 230 1921 145 400 505 1139 1717 1930 816 2348 723 1889 104 1560 926 1591 806 1931 657 1291 772 1621 517 869 625 1796 350 1237 186 817 165 2231 1657 1918 734 1389 514 999 270 1165 1098 2120 239 1404 48 214 1913 2083 1254 1521 264 2131 787 2136 1481 2291 389 826 1142 1483 613 2015 857 1640 1928 2034 224 2382 1280 2301 939 1171 236 1363 256 771 177 822 229 976 198 2116 1574 1694 558 1872 288 1499 1335 2082 861 1597 1813 2179 382 1997 2045 2354 599 1026 1056 1445 56 256 1020 1474 1173 1469 1523 2146 284 435 143 1356 1289 1322 759 2253 122 1842 1015 1186 461 2000 1295 1589 1178 1360 607 1689 175 1004 290 1880 15 1908 340 599 70 739 1144 1213 1902 1938 372 1685 1995 2220 491 808 239 1132 1172 1306 1004 2289 73 2089 648 1146 1103 14…
Output: NO

Constraints:

1 <= n <= 2775; 0 <= m <= 5550; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Last bridges of Elowen - MEDIUM Coding Problem | CodeTikki