CT64821

The Peculiar bridges of Clerk

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Clerk found an old ledger of bridges in the aviary attic at the port of Emberfall. The margin notes pose a precise question. 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 <= 1920; 0 <= m <= 3840; self-edges make the answer NO.

Example 1:

Input: 439 3430 11 210 277 297 2 218 87 220 127 335 162 421 128 193 283 390 271 359 98 359 259 335 48 416 186 188 184 286 149 373 81 406 5 13 62 306 116 211 186 390 7 183 171 251 348 437 102 336 126 439 61 373 200 382 150 312 112 366 117 317 18 20 65 81 236 279 95 246 301 323 16 259 42 76 245 367 248 364 136 168 363 423 113 377 78 305 108 249 142 215 111 265 81 326 280 317 14 151 78 406 2 60 71 263 180 378 150 407 99 101 23 131 151 349 249 368 184 373 61 341 75 317 163 221 33 63 142 275 196 348 110 124 284 335 135 173 11 386 217 288 159 208 80 148 186 225 234 370 118 126 48 204 87 366 227 386 133 223 102 114 223 368 110 261 261 395 47 179 96 124 372 423 111 253 318 401 34 159 50 135 28 374 323 386 176 432 109 273 156 355 81 94 2 328 16 76 100 127 59 375 168 294 178 353 297 436 120 243 88 382 192 …
Output: NO

Example 2:

Input: 851 2340 1 2 2 3 1 3 216 738 221 645 372 442 53 653 234 711 717 788 723 736 220 554 92 110 201 507 233 361 229 455 81 810 303 691 393 813 72 850 190 267 243 309 490 505 349 641 489 656 375 694 307 389 168 684 167 739 589 767 320 460 364 431 637 783 260 386 413 549 118 139 476 576 40 556 246 632 493 761 273 412 127 258 137 841 44 321 31 666 495 842 608 805 458 808 665 735 245 247 210 505 127 594 647 771 197 789 20 774 194 427 577 839 326 619 280 613 255 593 44 789 112 666 386 754 627 763 292 773 220 639 27 652 27 59 579 848 85 530 67 440 207 806 146 179 233 618 146 659 401 726 459 607 70 746 303 832 249 705 94 596 679 823 12 283 583 709 354 361 558 717 194 705 746 819 459 848 275 286 617 734 693 850 27 220 16 195 180 466 412 523 363 749 279 646 310 362 385 765 66 825 632 768 93 413 742 825 …
Output: NO

Example 3:

Input: 305 1530 55 202 160 244 165 221 102 261 22 200 49 273 28 244 84 212 205 238 122 134 274 278 144 232 19 275 48 53 78 131 221 293 92 176 4 223 136 137 63 228 8 258 174 187 13 27 40 302 146 261 86 111 3 195 67 279 155 294 183 212 84 95 173 177 152 161 152 199 92 303 126 239 195 299 179 188 50 200 114 134 48 141 99 214 219 302 141 237 26 195 91 265 210 272 149 210 118 297 174 281 225 283 32 265 112 126 140 187 40 259 198 232 29 76 252 299 193 280 77 156 76 224 11 13 137 269 190 262 185 218 94 119 83 160 30 208 170 178 18 50 24 284 229 236 48 231 68 298 134 177 122 299 199 303 159 198 188 302 198 241 14 216 151 267 163 216 2 203 147 170 50 185 34 246 73 233 83 200 16 52 176 219 43 214 20 57 2 106 12 116 144 242 124 177 194 269 18 167 179 218 111 137 181 222 15 228 110 231 62 87 27 266 52 237 88…
Output: NO

Constraints:

1 <= n <= 1920; 0 <= m <= 3840; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The Peculiar bridges of Clerk - MEDIUM Coding Problem | CodeTikki