CT43941

Smoky canals Two Guilds

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the fox den of Rustwood; Trader weighs the day's canals manifests and starts the calculations. 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 <= 2187; 0 <= m <= 4374; self-edges make the answer NO.

Example 1:

Input: 529 2005 29 325 56 345 409 524 13 429 163 261 104 318 51 141 262 521 179 355 120 510 23 55 270 314 154 482 48 502 480 505 30 373 178 216 324 395 223 385 287 467 85 322 67 475 215 493 115 208 346 350 44 456 303 419 142 332 122 327 394 494 30 375 371 491 54 151 275 358 64 283 242 442 209 276 27 502 3 226 132 203 8 314 230 396 305 359 360 378 308 379 40 328 322 460 263 429 125 231 71 215 39 428 55 449 30 473 228 462 103 462 286 416 110 151 317 403 70 200 61 429 208 317 5 390 254 343 153 471 85 282 125 394 329 427 387 508 304 428 10 518 127 292 21 140 422 455 81 359 220 482 409 480 288 484 147 482 164 286 6 393 99 405 10 191 76 268 76 281 139 415 102 177 357 422 270 474 43 231 351 483 245 506 199 219 3 362 146 463 180 358 17 202 98 301 287 481 443 474 151 388 201 308 475 515 177 285 323 404 14…
Output: NO

Example 2:

Input: 1954 742 468 1499 602 858 357 1198 708 796 479 1816 1127 1939 1726 1892 371 1324 196 1646 364 545 1618 1894 1394 1558 210 1446 1704 1773 48 948 336 1403 465 639 487 1124 139 749 895 1203 616 625 426 1075 1367 1513 896 1604 420 675 663 828 727 1297 935 936 1271 1942 439 642 1389 1681 433 663 610 1891 1199 1908 818 1934 527 943 1148 1831 904 1497 1213 1934 205 786 407 788 16 1841 129 1267 138 1345 1168 1919 1086 1385 986 1771 975 1223 315 612 434 552 444 1273 119 1563 67 1244 735 1772 1104 1204 126 1281 1306 1805 299 1271 85 1149 849 1118 1114 1627 723 1853 631 1169 924 1743 1029 1524 13 1038 1165 1462 1661 1825 810 1083 396 1004 1056 1726 243 617 1558 1811 594 831 367 919 300 1767 104 900 1328 1356 1150 1681 361 1703 600 1253 240 1254 334 652 477 499 184 293 219 1926 1444 1506 1385 1552 341…
Output: YES

Example 3:

Input: 2007 4089 1 2 2 3 1 3 239 487 782 1327 124 1874 629 1923 305 629 137 1878 29 1514 817 1051 1206 1618 941 1735 969 1376 851 1720 43 318 266 732 1099 1394 275 921 958 1205 288 569 574 1466 966 1171 29 1712 228 644 1099 1908 716 1220 419 1367 822 1893 257 821 248 1751 1279 1728 369 1555 166 1623 1494 1728 1943 1966 229 1266 230 400 546 850 259 1633 652 1400 597 1377 116 1177 774 1674 983 1628 191 817 1282 1432 414 863 257 867 122 1244 194 1032 1195 1219 611 1166 39 1384 149 1221 450 1679 1121 1872 1138 1310 415 593 576 772 169 461 1320 1441 1004 1603 805 1503 457 725 512 1200 87 636 1125 1606 1240 1831 1721 1819 1024 1382 3 230 26 1892 619 1513 434 1042 1064 1628 423 1716 79 1710 1429 1521 520 1737 599 975 66 1213 88 496 294 1484 749 1716 998 1108 438 999 1540 1560 710 1020 27 1310 668 1306 5…
Output: NO

Constraints:

1 <= n <= 2187; 0 <= m <= 4374; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Smoky canals Two Guilds - MEDIUM Coding Problem | CodeTikki