CT59758

Eklavya's Bright Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Eklavya runs the ropewalk at the mushroom groves of Fungaldeep. Today the books show a list of bridges, and the numbers must be worked out before sundown. 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 <= 2796; 0 <= m <= 5592; self-edges make the answer NO.

Example 1:

Input: 2417 2431 1 2 2 3 1 3 753 1891 703 2335 712 1665 202 1566 374 2031 456 1123 90 430 891 2298 51 1272 184 223 489 1069 2219 2320 483 1308 1558 1582 1625 2374 757 2397 108 1825 2139 2238 773 1814 730 2346 203 1043 1071 1350 1089 2117 1111 1131 1543 1952 235 792 378 544 435 2217 845 1672 1550 2158 403 2354 346 2413 398 2255 437 1382 160 1917 580 2106 178 326 737 837 224 1189 596 978 1139 1849 744 1577 1285 2082 530 1943 693 931 803 1373 1494 1519 245 949 30 2323 1192 1913 1743 1862 818 1784 599 2051 242 2132 1183 1200 512 963 1128 2321 955 2004 409 2400 94 1894 1442 2293 196 1370 1939 2107 1139 1406 502 1005 1123 1305 1055 1408 1232 1355 331 1268 1074 1568 537 2360 785 2266 466 1403 1709 1860 264 2017 769 2286 678 1158 745 2160 1218 1444 1659 1831 757 1169 923 1074 247 1523 663 1859 720 2223 5…
Output: NO

Example 2:

Input: 1504 1274 579 1156 770 1396 846 868 1127 1488 1017 1166 20 261 375 1412 1094 1180 552 891 257 805 253 265 479 730 74 144 289 738 676 1452 215 719 174 695 635 827 165 498 157 599 74 1204 64 398 402 921 267 542 511 623 297 1122 432 1219 412 619 95 1186 1109 1226 244 1012 97 788 1246 1460 10 1059 1064 1254 344 1061 74 99 47 979 1141 1361 1315 1385 745 932 124 274 149 1038 79 517 281 1340 191 929 1154 1409 634 1087 230 328 220 1313 42 624 301 1034 92 728 722 754 1077 1246 1020 1230 1162 1371 422 1261 390 984 611 1020 587 1155 1317 1400 102 559 17 1007 1220 1304 275 1417 37 156 149 825 200 750 39 407 683 1201 493 787 914 1375 472 1141 75 1054 488 1036 108 1435 202 1429 523 1247 991 1388 608 1226 720 754 378 564 292 1248 62 397 254 489 544 877 1062 1241 1007 1357 1142 1413 579 1365 257 1145 1315…
Output: NO

Example 3:

Input: 753 2638 1 2 2 3 1 3 551 574 182 743 582 599 159 321 462 497 362 753 554 693 263 439 49 359 603 719 137 270 328 528 82 461 64 545 230 653 542 697 661 728 399 730 67 640 85 392 232 296 572 639 124 565 375 551 107 614 182 686 270 523 22 725 570 646 319 408 405 565 199 433 30 675 18 524 14 739 43 217 631 648 455 476 23 195 179 428 232 425 116 400 175 749 330 567 67 501 79 207 39 351 142 577 51 561 377 557 304 591 353 451 23 68 326 393 191 623 57 269 716 749 65 544 100 186 60 392 10 735 412 678 693 714 211 629 368 561 104 213 368 721 415 417 119 224 601 652 321 350 103 519 1 456 187 485 33 287 245 588 16 749 201 625 295 585 345 727 293 581 375 520 38 515 2 329 460 589 248 253 291 562 92 688 339 736 29 324 220 658 414 721 38 561 182 324 18 329 360 404 112 313 31 427 153 747 156 627 268 506 424 …
Output: NO

Constraints:

1 <= n <= 2796; 0 <= m <= 5592; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Eklavya's Bright Ledger - MEDIUM Coding Problem | CodeTikki