CT39678

Maya's Ledger of roads

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the alabaster quarry of Whitestone, Maya studies rows of roads 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 <= 2941; 0 <= m <= 5882; self-edges make the answer NO.

Example 1:

Input: 424 5391 1 2 2 3 1 3 86 159 169 190 60 371 364 416 33 418 285 353 48 277 35 354 64 423 169 235 218 247 260 404 351 386 143 218 22 265 340 411 106 232 136 417 174 311 323 328 176 184 36 121 50 151 15 34 201 294 37 123 149 155 250 395 272 320 126 183 225 320 5 62 70 231 289 295 114 235 72 134 139 215 122 347 12 99 170 384 198 387 88 255 34 322 62 276 165 167 251 260 251 311 77 109 221 335 47 100 1 263 59 257 106 279 15 162 167 378 88 233 42 218 127 128 170 288 70 100 2 13 50 112 95 342 230 264 325 388 207 216 262 365 133 396 13 284 105 308 7 417 335 416 99 133 225 363 264 272 69 220 25 114 66 289 152 303 86 328 300 305 72 217 87 247 5 346 36 403 201 247 189 404 83 361 74 368 168 182 197 222 95 409 24 374 122 283 81 365 261 319 205 338 11 228 108 262 9 200 106 296 41 178 2 24 18 237 239 352 1…
Output: NO

Example 2:

Input: 673 18 115 216 18 192 149 601 211 235 202 565 483 639 596 623 387 510 141 493 138 669 445 606 494 559 450 656 447 569 341 466 117 296 380 643 641 645
Output: YES

Example 3:

Input: 1457 2711 460 888 48 502 309 860 468 1098 289 1118 476 855 250 326 692 916 362 530 649 1285 496 892 423 1435 626 1326 701 1228 820 987 360 452 360 916 280 444 593 1349 194 324 227 974 483 1404 90 459 178 234 179 991 592 698 1177 1183 295 1377 951 1087 992 1050 433 497 757 1388 394 598 49 1256 575 810 287 1077 380 809 775 1448 312 875 901 1285 356 966 290 1293 764 875 838 1403 460 633 523 1103 727 1206 418 763 324 482 408 1388 511 1095 267 964 36 1447 797 919 254 735 426 720 849 1295 12 1384 961 1189 57 1132 315 445 475 1342 466 766 312 1012 679 1194 1047 1346 978 1308 390 1202 501 1172 434 874 250 1383 961 1368 1190 1452 229 564 295 870 1321 1423 690 843 870 1372 250 649 482 1310 823 1393 460 823 322 663 422 743 645 1278 426 731 886 1218 713 1444 130 768 1110 1304 826 1033 22 230 733 1263 …
Output: NO

Constraints:

1 <= n <= 2941; 0 <= m <= 5882; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Maya's Ledger of roads - MEDIUM Coding Problem | CodeTikki