CT58532

Last tunnels of Pavel

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the herring shoals of Silverfin, Pavel the tallyman keeps careful count of the tunnels. plan the beacon maintenance rota, 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 <= 2630; 0 <= m <= 5260; self-edges make the answer NO.

Example 1:

Input: 2193 5017 363 1684 256 1106 1208 1538 1757 2137 332 1272 537 742 697 1975 53 526 84 1145 127 796 1087 1796 730 2148 734 1389 40 522 1239 1458 1570 1868 1330 2063 868 1387 614 1736 712 788 935 1952 65 1944 1335 1384 364 410 176 364 544 1529 1857 2035 1079 1714 264 788 937 2013 55 235 718 1552 141 1709 38 2006 291 307 1743 2095 1943 2006 321 1689 253 2171 88 1603 247 845 1295 1417 440 1521 1224 1541 1366 2014 245 1110 1396 1541 978 1395 423 543 187 898 607 749 401 908 225 523 404 872 283 1036 847 1555 685 1776 1388 1503 881 2077 1072 2032 1455 1534 1129 1975 515 1682 449 750 1574 2034 1946 2014 55 865 772 1557 405 1436 472 2054 453 1159 775 1339 1428 1744 1080 1253 486 1657 203 1005 567 1050 150 581 1388 1402 1790 2167 1337 1888 1985 2043 1656 2105 1490 1615 646 1437 1803 2129 551 1798 341 1…
Output: NO

Example 2:

Input: 721 5237 1 2 2 3 1 3 104 567 487 582 269 444 404 674 13 405 124 564 390 456 88 476 126 173 312 533 167 389 124 157 335 400 222 555 92 179 219 489 5 420 39 495 112 359 157 163 591 717 190 552 500 504 370 421 390 591 214 372 41 123 142 577 491 648 310 357 275 530 154 162 286 395 166 391 504 523 442 682 116 251 111 365 16 362 262 513 450 527 71 481 433 497 151 642 471 620 200 441 168 279 309 649 380 440 39 102 39 534 6 443 179 349 254 372 354 677 197 704 163 223 323 518 142 326 240 311 260 708 36 483 99 529 131 541 331 470 98 675 209 374 634 692 286 715 245 577 561 606 259 513 312 713 260 338 308 412 74 134 628 655 71 547 316 586 71 568 338 641 171 296 100 203 28 209 419 637 333 578 211 692 7 619 369 594 271 644 107 634 190 569 455 720 109 188 146 562 32 188 20 208 313 443 151 477 168 386 42 …
Output: NO

Example 3:

Input: 1499 4979 1 2 2 3 1 3 116 724 837 1204 124 945 209 356 312 1133 138 348 582 639 644 769 4 1273 724 761 443 459 382 1070 259 1480 93 138 1119 1155 287 431 696 1278 35 477 364 520 315 795 27 359 470 1424 89 999 34 1436 81 926 885 1201 522 1394 421 1395 671 1418 897 1003 132 1404 367 369 323 856 663 1153 689 1402 89 1371 807 1415 455 544 1317 1499 2 32 443 520 1181 1197 560 1478 873 1135 145 1179 451 972 688 807 937 1476 589 1308 1235 1279 400 1127 1159 1255 822 1415 621 970 58 1157 201 871 460 1341 197 607 1292 1376 348 524 199 591 243 1229 710 851 82 1212 477 651 41 1494 812 1152 492 1048 678 712 6 1493 226 1011 180 1304 29 1192 754 826 155 1216 1346 1359 426 580 649 1307 814 1074 1066 1152 1098 1363 153 1321 1086 1362 229 1299 733 1369 114 1169 572 1078 689 785 909 1328 425 1258 366 1499 8…
Output: NO

Constraints:

1 <= n <= 2630; 0 <= m <= 5260; self-edges make the answer NO.

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