CT43443

Nina's corridors Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the indigo vats of Bluehollow, someone must certify the cargo before shipping. This year the task falls to Nina, armed only with the corridors register. Task: Print YES if the directed graph contains a cycle, otherwise NO. Input format: First line: n and m. Next m lines: u v (directed). Output format: Print YES or NO. Constraints: 1 <= n <= 1567; 0 <= m <= 1567.

Example 1:

Input: 967 1332 397 130 317 193 50 717 330 747 586 492 917 176 275 58 540 930 398 206 783 520 962 294 114 533 447 450 841 791 539 790 699 200 679 22 524 284 675 250 472 831 824 447 116 581 693 304 15 661 90 658 647 697 526 578 586 614 510 801 711 922 832 892 840 198 11 441 277 93 16 285 292 233 586 407 10 796 590 211 125 487 6 809 4 201 818 644 911 959 216 330 543 130 38 121 801 515 534 64 909 57 691 601 450 355 774 377 281 544 369 514 792 496 159 463 819 265 406 154 185 120 304 625 143 317 930 793 617 916 274 345 815 636 671 704 264 58 826 558 492 520 231 440 260 914 225 98 827 188 400 752 485 460 360 75 270 724 615 425 10 71 494 780 667 104 259 731 383 610 555 631 173 486 577 7 147 67 903 365 579 82 496 110 140 90 14 450 88 879 936 689 567 219 762 510 841 5 458 489 887 461 500 723 427 967 618 7…
Output: YES

Example 2:

Input: 561 184 507 25 109 148 397 300 461 227 62 289 323 432 110 280 232 545 307 245 291 45 386 270 453 260 382 237 203 475 58 173 448 284 318 434 544 302 394 222 268 465 225 544 459 536 131 533 177 97 93 52 324 442 181 211 153 196 183 517 131 516 106 170 173 494 485 188 521 153 495 106 309 186 259 65 497 522 127 470 252 520 546 6 146 355 493 226 297 299 526 351 338 498 128 424 109 545 451 332 493 380 310 88 332 133 337 426 446 124 555 188 479 315 437 105 376 201 335 272 345 507 437 312 211 203 503 182 165 371 8 280 96 54 154 52 498 442 264 27 350 126 163 514 20 63 278 116 147 156 522 1 178 113 316 334 194 75 254 467 352 109 77 264 394 153 111 44 181 40 509 56 218 549 353 409 404 260 466 371 13 205 171 326 446 527 277 171 149 40 334 399 17 436 473 444 311 319 431 354 30 491 200 509 302 8 70 8 52 …
Output: YES

Example 3:

Input: 464 265 261 275 459 353 183 172 214 113 271 411 369 431 393 43 90 325 136 146 440 97 438 185 291 92 5 190 336 193 300 390 68 414 183 304 3 373 441 220 399 119 27 434 228 230 273 457 353 106 87 301 87 399 132 325 326 358 393 130 45 121 186 43 207 460 117 87 263 117 52 419 161 440 143 127 1 2 245 144 133 46 87 447 41 332 296 3 286 200 61 231 263 152 300 323 2 283 402 25 273 424 351 229 72 297 112 203 293 6 90 61 142 85 131 450 404 50 308 455 401 353 181 74 249 230 21 105 48 370 176 17 183 377 357 62 332 86 76 389 20 349 456 338 443 231 49 186 357 267 139 132 296 251 180 137 126 32 232 27 408 235 235 283 284 175 437 372 7 35 47 297 113 456 432 67 451 40 181 58 313 421 148 13 336 37 191 346 260 450 141 128 273 8 28 390 33 346 87 249 250 24 89 461 210 93 150 105 405 351 165 27 107 324 69 283 19…
Output: NO

Constraints:

1 <= n <= 1567; 0 <= m <= 1567.

Loading...
Test Cases:No test cases
No test cases available.
Nina's corridors Reckoning - MEDIUM Coding Problem | CodeTikki