CT50468

The Circular Route at Cindercrag

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the ember mines of Cindercrag pays by the answer, and Manav intends to earn it. First: the full register of bridges. 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 <= 3958; 0 <= m <= 3958.

Example 1:

Input: 3259 3549 812 1246 2977 634 966 1550 2986 1608 2812 2175 506 319 1537 1337 262 224 854 424 662 1533 2701 3175 1635 1480 1930 2387 645 207 169 70 3233 1123 3104 575 3229 1789 1692 2592 1470 265 783 2581 2184 1809 309 632 2296 2373 2917 2551 9 2512 496 3214 877 2909 2893 2905 874 29 2480 2160 1888 2633 30 296 1182 1107 341 1970 1534 924 1616 2774 1698 12 642 2046 1024 355 2912 695 2987 406 569 1952 1259 996 1479 2443 3083 1068 477 2612 3204 1560 2348 208 1652 3129 1478 2079 1444 553 623 1729 995 2981 2556 2178 1223 1652 2634 3238 1327 2627 154 2882 3053 890 2040 1344 3212 220 1924 6 1029 3055 819 2634 2814 2795 1205 732 2774 1897 36 984 1662 1025 520 2834 1641 2702 2682 1357 2635 2583 3229 1475 312 1673 756 850 3181 411 1292 2739 2768 2024 330 254 470 147 898 628 3086 1380 1554 1186 1423 181…
Output: YES

Example 2:

Input: 3644 2170 3108 155 2446 2688 3478 186 636 1789 1761 2008 3135 763 1936 1586 2059 1183 3068 2295 928 2014 1478 1424 884 2108 2987 132 851 2629 1305 2637 130 3414 863 90 73 203 2967 1123 669 2331 3633 3031 2910 2086 3261 1679 1207 1501 6 1172 3225 3354 2816 2154 3067 1208 1012 1048 1031 3102 1431 3022 3482 855 2997 689 223 194 1446 2052 374 1341 2476 2 1746 3265 2421 286 2670 2431 854 1005 1845 2807 3248 3056 1749 3220 2975 855 1715 3396 2858 3551 3333 1419 468 1187 228 2790 305 2914 3599 828 2243 2672 2147 3289 2957 1526 671 1283 992 2230 728 3300 3440 813 2762 41 949 3638 1877 397 1009 3498 2009 3279 814 857 3243 1023 2535 2929 1981 2155 440 265 1251 629 2530 60 1775 2587 1941 1362 3311 1203 2853 3076 3323 959 3071 3177 1752 229 2201 2075 2769 3397 3432 1373 1144 2173 2335 1269 2122 1405 3…
Output: NO

Example 3:

Input: 257 3829 41 225 204 81 202 178 222 226 119 140 236 239 150 18 146 122 93 182 257 243 46 217 101 56 111 154 160 48 75 216 123 217 14 134 192 63 123 243 227 199 164 47 43 41 112 81 54 12 187 192 88 39 245 81 228 98 198 117 152 221 56 189 71 186 250 143 197 212 203 256 54 38 29 9 219 239 174 105 49 67 178 171 192 130 55 172 218 109 140 70 112 59 5 48 119 104 148 28 94 221 5 123 105 256 169 123 190 196 21 37 224 158 173 78 112 187 154 159 212 49 254 19 57 227 26 187 82 203 25 243 23 224 120 88 183 244 244 16 26 210 224 223 133 180 168 129 175 239 238 172 146 152 131 177 126 218 99 217 207 113 194 111 40 5 133 166 54 158 5 6 56 185 177 8 21 214 216 121 21 240 194 105 49 142 133 169 144 213 47 143 63 243 99 118 85 166 133 198 28 29 98 159 194 256 235 189 217 78 214 24 247 80 190 21 104 176 88 64…
Output: YES

Constraints:

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

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