CT58899

Envoy Counts the corridors

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the obsidian flows of Blackglass, Envoy studies rows of corridors entries. One clean number will settle the guild's oldest argument. 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 <= 1407; 0 <= m <= 2814; self-edges make the answer NO.

Example 1:

Input: 661 1200 1 2 2 3 1 3 381 495 314 473 273 562 219 414 208 319 151 156 22 408 556 636 239 455 129 614 362 407 361 634 471 531 106 239 121 519 245 435 93 441 577 620 112 314 123 532 164 402 103 180 131 620 407 513 253 460 382 604 208 605 103 539 233 464 201 231 78 594 7 129 437 443 175 208 259 282 248 393 192 316 59 641 134 432 365 547 275 448 264 433 416 524 307 388 158 305 206 555 75 499 52 547 192 272 78 243 67 111 227 526 75 544 45 99 225 294 273 618 479 524 186 611 109 598 52 201 24 661 155 633 245 537 13 19 5 167 384 396 240 412 382 394 449 629 80 142 109 600 191 656 228 420 124 512 347 644 118 382 183 279 377 640 151 426 103 456 25 82 251 390 188 220 106 333 249 447 51 271 8 628 307 641 76 183 57 319 339 444 83 302 24 229 145 420 510 627 120 467 25 87 63 156 60 330 11 115 155 596 340 4…
Output: NO

Example 2:

Input: 668 2380 108 256 317 353 356 508 209 232 215 328 17 330 510 554 80 377 46 387 348 609 202 482 228 320 457 488 443 455 248 659 83 319 539 583 34 207 305 533 90 379 79 191 193 354 216 466 202 550 81 516 162 496 11 320 181 577 485 527 44 96 172 484 587 603 427 597 345 453 206 579 64 645 203 221 103 545 40 412 98 497 87 469 150 259 268 578 152 572 225 243 118 408 421 520 264 489 457 601 285 648 268 275 434 608 161 497 181 664 47 290 396 437 182 202 156 347 98 202 70 666 171 395 289 512 419 646 404 556 181 275 321 568 37 607 165 623 119 662 351 644 139 599 3 172 131 318 363 562 172 275 157 232 177 303 445 544 263 507 248 458 259 668 89 415 33 590 269 327 377 555 469 578 36 490 91 94 108 151 537 568 519 557 169 191 111 639 67 661 149 645 18 633 12 412 228 575 207 210 2 71 235 398 293 663 500 586…
Output: NO

Example 3:

Input: 54 291 9 15 31 48 2 21 17 46 9 44 39 48 24 44 8 39 5 54 41 50 10 37 18 23 16 28 1 3 11 17 9 43 35 54 42 47 16 22 14 31 16 38 42 53 5 11 6 29 41 53 18 38 10 38 31 42 27 29 42 52 28 43 4 37 48 54 10 16 23 39 2 11 40 45 16 31 3 8 43 54 34 43 29 48 13 27 24 42 38 47 41 54 16 53 35 38 2 30 16 44 11 15 13 46 12 36 29 43 22 26 18 45 4 52 22 52 3 27 7 37 14 38 25 54 39 49 5 20 10 24 9 11 36 48 21 50 30 40 18 53 17 48 4 35 13 33 4 29 16 54 22 32 26 43 31 39 32 54 18 26 11 48 30 37 10 19 23 26 30 45 20 42 8 54 12 27 18 43 26 49 9 16 32 39 23 36 25 47 7 19 26 50 19 35 17 25 19 22 7 41 7 23 19 38 13 24 22 33 11 41 14 26 9 30 25 29 14 29 26 41 12 50 15 17 4 6 1 29 18 28 41 42 1 48 20 38 4 26 20 35 15 41 37 42 28 29 26 33 44 51 23 27 39 54 44 54 29 30 25 49 8 48 32 40 3 26 21 46 21 29 6 37 25 45 14 18 1…
Output: NO

Constraints:

1 <= n <= 1407; 0 <= m <= 2814; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Envoy Counts the corridors - MEDIUM Coding Problem | CodeTikki