CT58296

Nandini and the Two Guilds

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the heron rookery of Longlegs as Nandini unrolls the day's manifest of routes. The tally will decide the next shipment. 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 <= 1447; 0 <= m <= 2894; self-edges make the answer NO.

Example 1:

Input: 426 665 364 416 1 92 191 247 138 313 17 188 109 224 162 325 56 118 110 181 368 391 333 391 179 387 1 257 171 384 186 367 347 423 158 391 56 170 220 318 212 392 357 378 229 346 77 187 41 101 80 247 17 31 86 281 97 236 112 207 259 302 111 185 298 368 55 242 230 305 259 301 109 273 219 242 252 269 64 91 120 270 221 338 75 415 186 246 60 379 147 182 48 92 45 158 82 101 73 248 305 411 90 98 51 352 32 43 219 227 176 337 94 389 268 387 258 411 5 285 231 254 171 281 35 216 68 382 37 46 163 403 210 415 120 149 325 411 80 329 52 142 239 390 114 426 300 325 302 424 225 238 22 254 172 374 230 360 237 361 45 395 251 271 240 267 2 277 266 367 91 335 303 355 357 380 349 402 246 415 318 421 144 307 155 399 253 404 286 349 54 265 153 223 76 401 62 96 74 409 29 277 163 295 207 395 174 405 94 279 145 383 145…
Output: NO

Example 2:

Input: 486 1758 1 2 2 3 1 3 73 440 274 431 89 382 151 216 79 151 324 472 327 387 74 227 163 296 199 452 33 426 283 304 39 65 298 470 210 223 111 477 230 454 161 295 157 178 36 340 36 336 338 384 19 378 241 460 161 362 25 462 375 445 281 423 238 417 394 447 278 379 3 199 200 205 86 471 210 356 45 467 9 424 359 380 132 277 65 305 10 138 82 455 53 123 276 320 316 465 108 354 132 163 235 486 161 294 52 99 221 432 148 208 343 424 89 415 184 245 123 418 60 76 403 455 55 386 293 294 124 151 77 153 85 335 87 215 66 154 90 237 339 462 187 409 176 290 35 109 257 285 61 218 148 248 197 430 27 374 37 365 21 195 70 388 416 427 261 365 337 394 284 293 51 243 150 302 303 324 172 249 144 183 183 206 237 242 157 466 152 282 294 352 183 354 113 316 174 221 82 201 120 155 350 366 218 262 155 448 24 132 12 377 286 4…
Output: NO

Example 3:

Input: 452 489 164 207 110 258 134 167 109 142 58 210 145 181 47 243 202 439 7 381 52 217 256 394 154 322 216 266 83 90 54 286 99 373 218 324 267 360 253 352 34 241 121 263 32 139 18 192 266 292 293 448 103 310 162 397 77 84 45 251 426 443 166 431 41 296 93 120 6 389 45 80 129 197 29 194 367 430 13 340 140 259 192 246 85 180 299 359 78 329 37 147 287 318 124 333 158 441 150 217 78 98 227 300 178 292 31 279 234 274 104 214 211 374 308 333 263 444 199 423 9 257 144 372 354 410 54 357 197 411 306 434 48 135 168 343 350 438 142 175 7 312 381 442 163 409 44 168 101 204 11 197 202 231 97 387 265 268 228 404 117 432 396 399 118 288 15 414 183 310 61 354 72 119 168 392 71 291 158 255 9 162 150 260 54 426 152 156 87 418 390 425 207 300 43 324 257 299 255 385 33 315 261 409 12 222 296 442 301 390 389 402 1…
Output: NO

Constraints:

1 <= n <= 1447; 0 <= m <= 2894; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Nandini and the Two Guilds - MEDIUM Coding Problem | CodeTikki