CT58013

Jaya's Ledger of routes

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the pine barrens of Needlepoint, Jaya 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 <= 1340; 0 <= m <= 2680; self-edges make the answer NO.

Example 1:

Input: 1215 2033 1132 1158 931 1001 276 448 167 1033 970 1102 370 967 241 898 397 516 263 781 550 1163 227 1215 84 814 976 1209 190 930 21 716 438 1028 422 970 453 757 17 792 58 1207 659 787 325 618 490 876 19 494 474 632 260 1172 530 1151 81 333 222 870 498 989 678 903 251 890 246 576 324 1153 706 1060 381 988 594 1070 97 196 526 875 4 1008 517 934 138 1059 526 810 122 715 756 936 234 1122 189 797 439 1099 224 687 20 694 17 718 30 128 131 522 242 763 113 542 512 734 56 597 49 925 880 885 655 1209 515 1112 233 1194 395 515 198 843 455 959 1197 1215 413 634 231 554 97 555 617 954 162 341 623 664 570 1046 490 726 61 432 97 727 187 548 129 987 274 1186 11 92 644 762 124 440 779 994 516 830 353 1159 226 949 468 1002 199 204 848 938 526 550 841 1174 307 322 100 996 218 1125 143 953 355 1152 15 228 471…
Output: NO

Example 2:

Input: 431 615 1 2 2 3 1 3 280 372 36 317 16 124 104 274 247 296 88 159 247 353 134 352 17 406 236 385 108 268 271 278 28 126 314 378 82 174 196 408 193 396 353 395 103 104 318 333 328 374 36 389 37 58 316 374 7 317 74 394 175 349 255 403 45 189 76 395 80 144 63 251 149 224 48 342 135 216 209 217 45 74 57 301 24 350 228 394 257 313 381 384 153 241 121 173 193 239 20 230 121 340 68 382 366 421 54 232 143 187 132 261 3 405 95 241 33 361 231 289 126 269 94 341 364 418 97 431 232 310 40 65 112 370 388 423 211 369 235 268 285 366 252 269 129 386 312 427 94 224 30 122 162 241 65 128 271 363 218 240 96 312 155 162 79 105 177 285 26 344 215 369 351 391 83 237 130 301 133 153 73 296 169 411 265 363 152 182 143 369 144 340 134 415 58 142 319 411 13 251 92 347 116 415 215 396 107 308 53 131 51 56 81 396 114…
Output: NO

Example 3:

Input: 528 373 88 510 48 195 300 414 71 374 393 521 135 147 24 456 276 456 25 169 172 470 288 297 33 420 464 523 325 395 439 524 69 296 358 520 38 514 93 414 361 496 4 354 120 232 317 380 289 521 9 200 186 493 32 155 201 316 145 214 232 518 246 346 202 444 183 345 299 335 158 174 298 351 60 492 34 344 440 511 261 415 299 356 123 443 231 408 170 427 229 477 258 262 149 303 310 383 87 116 371 448 252 509 234 501 339 381 2 174 21 98 287 306 128 344 81 121 325 502 186 423 69 498 55 345 148 410 103 515 110 232 119 155 213 284 243 365 266 491 91 119 111 198 58 198 8 506 431 509 169 305 342 464 335 519 325 454 371 456 112 264 275 495 223 406 183 225 83 344 14 486 375 451 417 518 310 362 127 333 98 362 66 253 72 128 53 490 86 196 133 525 73 520 74 257 100 369 362 485 118 243 103 437 13 442 220 362 465 47…
Output: NO

Constraints:

1 <= n <= 1340; 0 <= m <= 2680; self-edges make the answer NO.

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