CT50079

The Topaz tunnels of Silas

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The valuer Silas has been asked to plan the harvest festival. On the desk lies a long table of tunnels readings. 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 <= 1310; 0 <= m <= 2620; self-edges make the answer NO.

Example 1:

Input: 1279 586 189 1034 853 926 1225 1239 155 665 534 741 219 324 332 844 91 865 763 1056 104 1114 54 557 454 1025 587 849 44 698 724 1266 53 562 303 823 303 744 22 422 318 927 697 1180 69 754 229 1190 619 1181 517 740 821 954 291 669 74 345 492 505 302 445 5 149 835 1138 567 605 232 713 527 1213 101 1197 517 837 839 1062 539 1255 574 1173 169 196 537 582 237 696 1021 1265 555 1257 566 808 1038 1187 147 1260 212 573 421 1186 11 803 215 773 542 930 247 501 491 507 235 679 187 193 491 1078 600 724 774 1102 219 997 495 707 736 1214 47 378 220 717 334 431 63 1062 926 1155 372 841 373 491 508 830 1003 1202 829 1274 318 847 360 656 125 184 154 703 278 946 673 1210 192 604 797 1210 993 1224 751 964 126 602 27 68 334 418 557 614 679 1100 502 1221 65 1083 216 608 914 1184 312 442 61 542 378 1190 168 946 …
Output: YES

Example 2:

Input: 617 1924 336 362 56 94 71 383 134 612 121 436 33 180 48 256 380 418 12 272 190 371 16 520 95 536 143 530 63 178 50 452 62 118 255 489 145 607 79 229 40 453 295 390 361 567 436 476 70 150 110 531 20 265 106 163 266 497 168 308 228 587 141 247 423 605 543 608 135 431 80 99 310 416 3 331 30 493 48 344 94 237 188 498 108 211 97 221 195 382 154 366 187 349 98 151 47 325 64 441 154 406 380 440 183 304 298 562 68 402 256 290 350 389 257 544 27 309 327 366 266 323 452 603 386 602 63 451 390 592 543 552 274 405 150 502 574 593 258 574 207 227 63 206 266 290 411 596 46 122 95 612 184 251 49 336 510 552 25 219 357 611 465 545 295 304 222 478 224 378 237 494 103 118 6 25 28 94 405 406 113 410 343 389 214 325 374 581 53 336 311 325 170 197 398 475 214 398 436 581 135 518 572 609 426 604 399 457 82 290 …
Output: NO

Example 3:

Input: 263 2376 1 2 2 3 1 3 85 195 207 261 41 200 33 181 194 242 195 217 113 263 206 230 226 246 23 227 36 45 63 207 143 223 87 130 113 204 56 174 135 176 88 156 3 236 224 250 79 239 80 221 193 237 204 231 1 66 86 200 77 108 209 263 182 214 5 50 168 192 115 247 55 144 44 166 30 212 133 147 44 245 107 220 166 168 188 224 139 237 201 213 103 222 37 220 153 192 210 212 173 178 134 152 171 260 69 216 154 186 58 182 101 206 43 214 151 173 9 61 86 210 100 237 4 209 94 252 162 202 193 199 12 176 113 245 4 252 106 155 112 194 173 194 183 233 70 86 58 127 6 57 75 85 17 100 138 239 31 252 172 204 180 201 211 235 34 41 224 229 87 257 147 148 35 206 109 257 160 214 126 151 21 184 82 203 164 179 136 180 1 201 223 226 97 239 45 221 75 91 142 228 114 211 25 204 211 232 127 262 178 225 67 113 41 53 13 223 146 18…
Output: NO

Constraints:

1 <= n <= 1310; 0 <= m <= 2620; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
The Topaz tunnels of Silas - MEDIUM Coding Problem | CodeTikki