CT38498

The routes Two Guilds Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the opal reefs of Shimmerdeep, Ysolde records each routes in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2313; 0 <= m <= 4626; self-edges make the answer NO.

Example 1:

Input: 482 4221 385 472 179 416 92 363 210 329 41 337 123 418 235 298 212 353 270 285 51 209 173 342 390 449 238 467 182 272 241 320 116 289 21 101 33 207 169 435 18 25 26 416 17 387 207 422 67 393 2 166 208 400 143 327 155 408 116 192 270 358 412 422 142 223 26 203 40 190 10 333 34 342 318 462 405 464 78 294 297 377 320 397 275 376 275 482 194 207 146 342 134 153 55 394 186 449 18 372 312 344 147 480 368 440 187 445 18 40 19 175 180 359 317 424 28 434 190 297 166 227 42 134 275 435 33 244 221 476 16 142 374 442 387 478 108 162 130 132 351 422 178 454 131 399 330 380 6 16 207 214 258 322 396 433 27 311 211 376 131 359 362 391 171 289 221 285 88 360 211 482 197 277 238 384 145 328 79 458 198 252 70 403 102 165 48 202 62 90 63 355 51 316 134 305 59 337 330 472 143 441 137 304 76 130 104 212 62 320 …
Output: NO

Example 2:

Input: 512 1328 1 2 2 3 1 3 193 375 61 352 137 370 341 401 145 238 80 476 192 375 83 431 486 504 339 370 283 465 267 443 166 245 31 181 17 96 64 278 139 169 252 334 90 266 336 501 293 470 75 84 273 343 442 480 204 401 69 81 178 366 96 236 243 460 163 223 136 391 127 297 195 283 160 383 359 402 325 478 210 317 111 440 51 437 161 403 226 362 79 385 306 384 392 468 11 413 180 439 221 467 23 491 46 362 103 447 122 133 372 390 202 287 44 288 273 390 76 146 114 265 340 489 159 502 50 143 136 426 86 220 76 354 122 259 328 502 119 280 343 452 138 454 57 338 245 445 329 346 154 415 273 405 98 176 53 178 232 287 19 426 67 155 233 393 85 126 273 363 447 468 37 390 131 485 83 320 110 178 51 282 225 275 265 392 50 210 372 486 76 202 164 436 288 431 228 422 67 255 10 223 172 408 114 140 243 335 148 499 63 200 …
Output: NO

Example 3:

Input: 21 68 5 14 14 20 4 21 6 14 1 6 3 7 6 7 5 7 6 10 1 13 5 18 13 21 3 16 11 16 5 11 1 20 14 16 9 10 6 13 1 17 3 11 19 20 4 9 16 21 2 11 1 8 2 5 1 14 3 4 4 13 3 17 2 19 19 21 2 15 6 17 15 19 2 6 8 11 4 20 7 9 17 20 9 11 12 13 8 17 7 15 3 9 6 21 1 18 14 18 8 18 8 20 13 17 6 11 5 10 4 5 5 12 2 17 17 21 3 10 9 21 1 15 4 14 17 18 6 20 3 12 1 9 6 16 7 19
Output: NO

Constraints:

1 <= n <= 2313; 0 <= m <= 4626; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The routes Two Guilds Puzzle - MEDIUM Coding Problem | CodeTikki