CT44942

Jace's Verdant Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the railway depot of Cinderline as Jace unrolls the day's manifest of corridors. The tally will decide the next shipment. 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 <= 2920; 0 <= m <= 2920.

Example 1:

Input: 629 2050 42 548 540 26 392 203 74 495 169 438 406 11 568 165 573 214 190 174 343 360 320 41 474 486 99 412 347 364 626 334 524 463 57 604 600 230 189 47 224 280 600 194 272 219 12 312 18 50 364 85 426 595 610 550 185 389 345 391 373 548 406 367 543 100 21 581 307 461 369 291 501 593 25 132 262 560 497 344 58 327 267 185 37 160 314 233 150 385 392 463 71 274 145 128 165 580 227 285 98 293 250 592 349 203 192 184 170 127 471 449 446 107 359 37 396 339 150 528 70 9 250 368 148 456 564 585 443 14 370 33 603 15 59 444 446 67 330 74 245 173 388 20 296 480 78 411 129 352 292 279 359 611 555 45 144 410 575 257 505 368 392 244 73 524 171 252 147 168 258 398 26 211 580 214 402 193 550 513 246 551 532 438 284 212 309 425 617 457 404 249 204 580 240 565 549 579 2 344 446 356 28 415 147 26 474 211 455 …
Output: YES

Example 2:

Input: 1908 1151 812 84 1900 1162 1325 1880 1118 210 1827 376 1039 1171 298 1821 753 281 1174 1021 1874 1334 272 1118 104 449 725 896 529 1758 816 1394 1071 737 434 1718 179 1239 611 1162 1542 928 579 394 646 864 236 878 438 108 339 1799 353 1024 893 419 1597 1441 1485 1047 117 551 909 1199 822 176 270 121 294 281 1832 1431 1900 1324 1033 614 108 1379 814 1223 1596 830 359 1847 179 593 1276 1199 209 1599 1384 224 528 1444 860 370 801 1337 637 1814 320 304 1644 1873 1860 1597 1077 1574 1242 269 761 825 1458 914 1221 573 1111 1076 1395 1254 1498 482 755 107 180 1312 1538 1239 1710 66 678 1071 1727 828 869 1296 918 237 1563 442 25 1410 121 1651 1543 759 347 711 924 1778 113 556 1730 1734 1561 1657 789 1535 1421 1001 753 1776 701 1436 631 810 954 1839 1405 289 572 329 679 313 1858 20 675 1862 1408 18…
Output: NO

Example 3:

Input: 2086 311 827 1593 1199 756 294 1050 1108 785 1246 1938 1790 1876 1765 1152 1252 610 1335 738 783 712 1456 1723 2054 1473 1633 1248 1552 805 1634 871 274 2038 2033 426 1462 11 952 1074 1962 645 891 844 751 513 393 389 55 2008 406 1898 246 1649 47 1088 1152 1020 1731 663 1463 275 347 870 476 449 1131 1656 811 170 1906 800 1915 1807 94 1972 685 44 48 1594 1154 985 699 1248 1557 42 510 1744 2049 1398 207 1532 830 1847 1784 2032 1897 1355 1805 1938 1719 1249 220 374 1988 1058 645 1439 2028 1558 1445 2050 140 1961 34 326 1987 174 949 1032 658 386 109 543 1504 1891 1262 1265 472 1053 1844 1414 2082 234 671 1409 1945 1944 47 687 1461 213 175 300 837 819 1553 1819 237 1294 1368 1207 678 836 139 1492 1166 725 89 1716 1911 490 2035 1197 1174 454 1597 1522 1899 143 1744 777 1435 1191 2042 1036 1267 14…
Output: NO

Constraints:

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

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