CT46075

The bridges Circular Route Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the copper works of Verdigris with crates of bridges, and Maya the reckoner must account for every last one. 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 <= 2721; 0 <= m <= 2721.

Example 1:

Input: 2017 1069 1828 509 268 1054 1319 1764 1884 1539 261 1361 276 1974 1811 969 11 1795 1807 15 1171 693 1962 1688 253 636 798 1372 1591 1743 1021 185 988 2009 468 862 1148 1699 835 255 1344 460 239 772 1084 1909 961 426 1391 1440 599 211 162 1774 1275 1770 384 234 606 1966 564 143 260 1528 165 1503 467 1291 1806 1554 1742 79 451 755 1411 1358 72 1013 1753 323 1050 595 1925 1250 751 4 673 259 771 1889 1157 548 1117 240 1704 1321 2014 473 1094 1898 1259 528 189 1579 1655 771 1337 1748 1006 1462 1226 750 1089 1957 276 411 184 1293 845 743 855 852 1396 1193 1931 1581 1455 1899 1251 422 2000 854 744 72 1800 248 1892 1850 1594 1305 929 1199 1072 1871 1083 1635 186 1140 1559 762 927 484 989 818 791 1058 1887 1613 818 1862 1685 398 1455 471 623 611 1320 737 1505 89 1168 366 413 501 456 882 261 401 248…
Output: NO

Example 2:

Input: 224 318 119 49 1 48 183 103 30 205 207 168 199 177 112 30 218 109 27 41 149 186 150 164 121 162 185 105 182 63 218 191 189 159 133 11 156 23 79 116 36 136 222 34 55 11 80 125 83 10 67 104 105 91 154 40 171 11 204 106 159 112 117 146 77 18 77 54 143 154 71 81 97 15 120 57 224 96 179 202 40 86 75 100 151 66 224 131 111 208 11 21 93 220 113 103 26 90 74 53 75 69 61 224 169 20 27 177 34 28 190 203 141 189 133 20 95 55 28 16 23 164 17 57 209 203 59 95 31 20 91 92 159 129 52 77 1 222 179 80 183 24 162 166 188 195 55 206 110 101 164 135 192 186 205 97 152 205 96 147 194 68 103 37 41 214 122 2 128 213 145 51 62 31 43 86 173 74 82 169 82 40 59 179 222 75 111 186 27 91 159 217 65 211 77 212 160 199 155 218 67 4 157 62 142 7 101 71 167 191 100 70 122 8 174 120 20 215 131 24 127 126 205 163 94 20 8 42…
Output: YES

Example 3:

Input: 1325 2315 806 110 837 624 448 938 742 655 827 746 1092 700 793 850 1224 686 160 238 213 127 805 192 1083 1312 453 255 396 94 677 662 465 25 375 571 1138 789 356 787 1068 393 725 373 136 986 588 594 739 729 311 188 377 368 514 367 57 900 906 276 13 536 1102 1278 423 688 643 448 1126 901 850 842 1223 805 541 1186 175 1319 318 393 544 910 149 610 1282 33 918 1276 182 423 300 1009 1227 384 843 939 1196 255 95 89 101 252 294 109 861 766 951 913 632 462 355 12 1084 1172 798 632 708 943 354 161 998 894 699 373 874 764 738 233 286 1112 259 217 90 1281 61 1080 808 733 251 636 367 998 941 1041 892 23 762 415 368 416 619 153 1021 914 27 608 68 821 795 905 555 52 112 1319 1202 771 1303 1300 1265 170 1151 1050 1195 1236 638 462 562 795 126 355 910 21 805 694 44 940 248 1145 967 386 308 1201 105 915 854…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The bridges Circular Route Puzzle - MEDIUM Coding Problem | CodeTikki