CT48774

The roads at Verdigris

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the copper works of Verdigris; Koda weighs the day's roads manifests and starts the calculations. 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 <= 2805; 0 <= m <= 2805.

Example 1:

Input: 882 635 281 24 440 93 882 186 320 398 724 677 73 588 414 442 42 735 439 72 402 374 802 388 274 14 267 519 590 704 135 123 411 63 193 620 66 543 329 491 450 832 242 562 60 79 356 644 437 460 295 286 487 803 771 44 827 742 184 127 712 842 642 668 561 341 835 525 403 277 299 79 352 623 763 42 80 57 408 649 533 193 774 545 667 223 376 830 460 26 649 689 70 790 414 688 556 856 249 660 240 534 697 376 189 621 743 798 748 644 589 504 688 164 776 85 373 574 28 195 754 232 803 334 384 531 58 447 88 786 243 702 486 737 630 602 460 797 374 329 292 493 220 554 130 143 63 444 134 523 580 285 242 466 432 463 692 455 88 788 78 665 288 624 868 466 796 307 540 224 668 424 651 845 433 47 627 486 184 156 535 235 279 497 102 70 165 696 412 307 167 86 260 661 565 466 515 793 732 331 796 749 668 336 694 512 153…
Output: NO

Example 2:

Input: 1776 1406 1182 30 1616 1701 935 520 1661 1078 1453 95 1038 132 1395 575 618 316 717 1306 1372 854 963 1507 1239 660 1463 1392 1027 1520 1573 1428 1036 344 1475 729 1285 722 458 1166 1173 922 806 982 1774 377 177 441 87 1730 1171 509 925 380 1425 164 237 117 1663 398 520 285 939 1452 511 22 55 1761 1253 1298 121 762 800 1150 352 789 299 774 493 1668 1617 785 279 710 1593 1471 1366 417 1149 360 945 316 308 288 180 443 108 188 1036 927 860 260 675 40 1185 797 741 34 1236 874 759 1554 805 786 1604 439 1434 805 41 1730 244 1576 1613 109 1469 1333 760 1209 1759 769 251 215 1569 646 423 785 584 976 1401 620 1514 198 211 884 434 305 516 156 1645 1723 931 1189 396 479 1750 1393 1260 520 1701 333 759 669 878 509 561 496 870 512 443 760 1155 949 1746 279 1410 802 328 1407 1323 94 1728 1279 21 905 126…
Output: NO

Example 3:

Input: 2635 872 1436 653 509 788 1359 956 1421 1518 2527 233 156 458 1912 1297 1451 2378 2064 2258 1884 1553 692 2196 1882 2616 686 1720 582 1737 194 1599 1068 346 966 1390 2342 270 1394 1332 545 1194 337 900 678 1689 2591 302 909 2210 121 2233 1790 310 2070 133 2620 1280 1878 792 729 698 393 998 2606 2000 1312 131 2518 1819 183 1168 1876 2053 1312 487 706 2484 874 249 965 2562 2551 1005 1450 128 701 1596 191 2427 1968 240 2407 1889 2108 899 1267 2436 1340 2085 1805 543 2366 1922 892 2385 1779 2324 1100 22 846 778 387 513 574 669 848 1833 34 562 1522 426 2180 346 2398 718 369 925 2185 1412 1445 377 626 1692 1005 215 2019 345 2567 1863 1536 2521 1943 337 1988 644 1639 2455 2137 843 661 1085 1026 1887 2150 1674 377 943 591 231 304 1283 2578 11 2287 816 794 1558 1244 1652 1760 2098 1519 287 796 1606…
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.