CT61405

The Two Guilds of the Wild canals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the spice bazaar of Saffronia pays by the answer, and Elio intends to earn it. First: the full register of canals. 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 <= 2855; 0 <= m <= 5710; self-edges make the answer NO.

Example 1:

Input: 1817 4208 462 645 305 1213 1224 1233 139 720 697 1689 856 1681 793 1548 223 375 471 532 186 1702 669 1571 173 386 1106 1654 686 830 451 1195 453 973 301 1203 301 732 585 1142 950 1710 1367 1575 498 789 849 1523 211 349 251 1661 320 1523 612 1158 1119 1533 197 1191 418 517 904 1357 693 898 562 1725 371 904 283 1303 724 812 552 1470 927 1254 296 383 955 1564 507 902 684 1551 464 681 396 1444 783 1557 207 1602 322 530 133 928 657 718 1643 1697 132 262 798 928 390 551 1317 1413 1026 1569 425 1336 100 746 900 1208 281 935 61 429 830 1817 333 1517 764 772 262 393 475 1166 475 812 774 802 960 1086 715 1263 607 1262 1177 1730 689 1497 771 1440 670 1001 573 1020 235 1663 628 1109 324 1428 1025 1749 359 779 597 1108 884 1810 1068 1073 420 790 307 1729 1277 1472 1188 1379 1199 1584 701 1130 133 468 3…
Output: NO

Example 2:

Input: 568 2275 1 2 2 3 1 3 72 417 325 506 71 144 135 196 400 523 142 411 15 395 291 374 35 313 346 466 56 315 259 265 316 492 24 184 157 224 363 494 264 330 219 531 120 466 139 155 558 561 76 566 331 358 504 532 91 554 195 268 44 510 324 351 228 318 300 416 453 496 249 421 102 452 263 320 489 495 373 440 142 350 71 242 81 505 22 66 357 556 191 463 428 515 530 562 422 444 332 537 338 353 277 520 42 127 193 531 221 377 80 100 317 491 261 562 415 433 26 74 337 475 19 452 294 558 14 39 428 463 232 266 157 367 143 328 167 357 155 399 291 427 10 524 338 567 38 483 40 59 167 373 155 214 429 556 181 460 322 351 101 547 442 451 79 198 263 457 396 488 419 495 444 465 223 437 172 296 215 386 97 449 363 524 147 424 329 461 171 345 6 91 399 478 290 434 96 542 140 236 321 484 46 71 507 551 350 458 199 453 228…
Output: NO

Example 3:

Input: 371 3192 121 329 73 162 175 241 44 184 142 226 48 101 343 355 137 292 116 293 233 274 113 365 101 209 36 173 130 299 297 360 151 274 38 271 172 292 210 221 251 359 84 339 182 239 28 83 2 23 1 276 204 247 187 191 183 222 66 100 9 104 320 323 158 341 54 225 281 290 126 314 154 296 219 358 3 104 185 255 30 137 90 295 52 55 31 264 229 354 190 243 145 189 97 270 113 166 163 318 157 342 211 340 142 315 87 144 23 213 7 58 37 72 214 368 46 232 38 129 220 251 56 142 203 213 237 339 155 181 71 107 134 330 66 245 147 243 210 366 38 178 155 285 50 64 277 326 151 345 241 343 162 356 108 159 347 364 174 191 52 59 71 263 14 45 189 200 294 342 17 38 187 320 238 256 228 255 126 283 146 231 149 275 214 288 147 278 138 281 283 364 25 51 273 289 146 268 10 196 303 341 7 95 302 363 83 86 130 278 126 220 190 34…
Output: NO

Constraints:

1 <= n <= 2855; 0 <= m <= 5710; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The Two Guilds of the Wild canals - MEDIUM Coding Problem | CodeTikki