CT47497

The Circular Route of Screech Point

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the gull cliffs of Screech Point close for winter, Archivist must finish the roads ledger - one figure at a time. 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 <= 2229; 0 <= m <= 2229.

Example 1:

Input: 71 1995 38 40 23 3 59 57 51 24 19 36 18 43 40 23 11 23 61 20 49 16 28 33 52 56 9 60 51 16 54 25 6 14 5 65 64 22 10 70 48 12 46 11 47 24 49 20 40 38 38 53 41 29 3 2 41 52 41 3 47 48 6 21 31 37 28 30 33 38 21 61 8 12 11 67 24 44 29 20 28 36 61 24 41 39 6 4 4 32 66 70 39 35 18 65 41 47 67 10 53 45 63 62 4 9 52 5 37 21 1 36 35 65 7 53 17 71 37 43 25 70 22 49 52 9 43 31 43 57 37 24 38 22 26 20 70 27 57 16 21 43 58 33 53 26 7 39 64 24 4 51 53 18 70 66 4 41 59 38 60 17 56 52 17 43 22 3 60 23 8 44 4 53 28 12 57 42 67 31 66 19 5 71 30 27 23 30 7 12 9 41 25 28 39 28 52 43 35 57 50 25 47 15 26 49 69 58 58 35 58 14 36 60 47 33 34 38 52 55 55 20 45 44 2 60 14 25 60 47 43 12 44 52 33 6 18 42 53 5 26 37 10 1 36 35 39 64 29 50 51 10 27 6 37 40 32 23 17 62 37 51 13 59 40 66 7 62 7 3 32 66 33 67 31 41 42 62…
Output: YES

Example 2:

Input: 1644 1218 1061 685 1288 552 515 918 333 1170 797 719 1376 633 743 645 10 616 1569 1194 929 1553 510 506 970 479 811 1542 1065 1239 299 1422 450 905 1043 957 950 900 463 760 1225 722 55 1583 1436 1430 1049 1634 1292 1583 1364 1057 224 1584 1381 1570 1585 1339 944 1422 1051 18 861 496 886 829 466 729 534 1322 1420 198 391 448 1107 1639 509 476 1342 301 586 703 221 727 306 1475 1446 1412 475 619 1459 1191 797 1383 836 1639 1587 591 1362 502 626 1610 477 1611 1435 1572 1321 1333 515 1121 1002 631 1084 1105 1131 378 1159 483 1110 73 982 515 1093 174 1191 428 1585 888 1623 328 1128 1022 1380 1146 448 1468 1272 299 1190 1246 1414 1446 1276 86 1273 1191 344 597 3 1323 770 666 439 858 1572 1292 274 362 757 259 1600 1134 366 874 1372 851 274 308 1082 466 618 1379 1271 411 3 1378 578 1258 1168 1028 2…
Output: NO

Example 3:

Input: 1774 50 856 422 1263 1608 552 1570 318 537 1024 153 1323 220 1487 823 442 139 672 78 1223 591 405 102 485 147 903 233 1234 469 1744 660 647 785 743 86 198 361 109 1459 50 746 750 68 957 1568 101 374 729 139 711 1230 24 203 378 3 1055 932 1185 977 1685 993 455 506 117 593 465 1586 1090 593 251 68 548 908 1586 1654 732 55 215 46 377 1438 1763 33 270 49 1312 802 501 635 1398 824 132 797 721 149 1048 1132 1003 338 558 347
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Circular Route of Screech Point - MEDIUM Coding Problem | CodeTikki