CT64791

Diya and the Ember bridges

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the salmon ladder of Rushing Falls pays by the answer, and Diya intends to earn it. First: the full register of bridges. 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 <= 2566; 0 <= m <= 5132; self-edges make the answer NO.

Example 1:

Input: 188 813 1 2 2 3 1 3 30 184 21 101 94 180 113 180 60 75 5 105 32 185 70 128 17 54 34 44 54 150 34 118 156 160 89 163 52 136 179 183 62 89 16 141 36 94 33 34 20 121 21 90 101 170 27 107 56 65 62 155 55 84 40 141 67 175 66 134 6 82 9 84 14 18 99 170 96 161 26 37 68 95 37 67 67 74 95 129 9 127 52 106 2 171 180 184 125 148 7 105 14 29 1 123 2 153 42 174 34 166 97 176 44 62 22 59 61 99 59 163 38 73 36 160 13 117 84 114 4 72 37 102 35 71 62 74 25 173 24 175 105 181 50 52 28 115 111 160 28 117 27 173 16 36 95 152 61 110 59 129 6 107 132 157 5 121 172 173 38 124 35 48 77 148 8 111 61 98 126 136 168 172 116 169 118 133 79 103 128 156 87 114 57 179 64 138 109 158 145 173 45 185 94 179 92 106 22 188 131 141 27 111 71 99 104 175 53 122 9 94 42 83 91 147 49 174 45 148 2 175 102 171 20 119 124 133 17 188…
Output: NO

Example 2:

Input: 388 559 1 2 2 3 1 3 204 229 63 121 84 153 36 374 331 379 155 387 23 369 10 178 72 111 224 232 206 282 16 388 65 82 108 151 295 319 212 348 105 129 244 338 92 269 59 340 350 364 140 327 207 380 41 81 10 259 117 270 53 150 111 298 119 239 82 236 38 224 5 119 148 219 273 374 234 320 155 292 55 129 110 262 215 364 18 174 52 95 10 274 38 255 51 349 174 276 142 333 62 152 318 340 103 197 109 262 360 369 125 144 51 362 284 312 73 105 149 317 306 340 43 313 145 312 23 55 175 376 66 275 25 112 127 233 42 267 87 192 43 102 27 270 243 294 98 292 115 249 116 239 137 297 80 117 46 345 279 337 155 321 302 317 215 276 43 244 157 206 69 330 207 215 6 287 4 262 116 241 197 361 112 280 187 275 168 334 104 284 148 214 59 83 106 343 264 367 196 314 192 352 43 348 49 55 162 218 116 294 9 323 228 322 18 20 204 …
Output: NO

Example 3:

Input: 439 2601 195 338 112 272 253 290 161 302 232 344 113 137 15 393 223 404 77 149 190 276 22 100 30 135 111 339 296 357 25 306 136 340 229 266 98 321 200 300 65 310 124 174 124 194 69 104 152 225 239 307 208 246 141 350 31 407 259 274 127 433 265 348 27 359 82 379 125 357 210 431 23 328 114 330 241 353 157 309 38 359 238 300 217 299 227 378 72 198 196 226 92 434 175 420 210 319 14 74 2 431 28 218 6 23 157 328 65 318 8 78 37 356 32 78 42 383 15 23 151 390 79 94 103 206 254 326 173 401 51 246 359 362 71 299 27 388 431 439 178 426 114 351 64 132 180 270 320 396 248 369 251 328 116 270 51 172 50 372 65 194 134 223 312 413 133 237 70 347 29 119 208 421 305 370 363 431 63 370 215 395 144 311 303 415 347 407 5 35 97 383 259 301 49 94 141 362 90 259 173 347 172 226 191 268 214 246 260 390 71 373 299 …
Output: NO

Constraints:

1 <= n <= 2566; 0 <= m <= 5132; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Diya and the Ember bridges - MEDIUM Coding Problem | CodeTikki