CT55928

The Buzzwell Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the honey farms of Buzzwell as Kian unrolls the day's manifest of bridges. 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 <= 1419; 0 <= m <= 1419.

Example 1:

Input: 210 723 169 177 26 85 136 80 195 176 189 28 163 49 165 180 169 189 41 142 32 126 139 88 169 185 135 11 26 145 110 177 155 126 134 46 20 127 194 36 172 36 144 21 185 165 131 189 125 31 3 7 185 118 114 62 67 90 142 21 51 139 65 163 13 153 57 103 101 81 25 132 195 168 184 92 16 149 7 59 140 144 176 100 202 58 64 202 129 33 102 59 62 150 113 111 198 167 15 25 130 59 122 96 205 73 133 42 47 4 176 108 74 196 8 160 9 76 50 131 10 137 57 4 201 163 34 204 45 9 104 73 112 72 135 126 184 55 73 160 10 62 190 170 153 37 150 122 180 3 165 199 9 97 110 117 194 97 161 70 152 28 190 60 87 107 76 72 176 26 122 8 197 78 37 134 134 63 45 4 136 198 46 94 203 58 150 48 196 23 132 74 29 184 47 127 200 197 89 114 60 14 116 75 209 170 26 103 184 105 133 134 206 92 156 81 102 180 102 134 11 144 93 157 74 163 98 53 …
Output: YES

Example 2:

Input: 1051 352 1049 564 83 268 314 709 650 164 275 693 419 688 218 213 14 996 176 254 30 351 799 1021 314 94 624 393 28 589 189 194 124 226 795 967 188 702 921 542 967 986 164 441 508 608 751 556 691 1034 195 492 843 670 195 722 380 876 75 775 904 98 922 645 122 1034 764 314 470 655 664 497 405 974 239 303 938 245 889 645 981 903 355 204 771 470 361 22 54 440 462 842 164 418 585 456 1013 172 942 85 456 466 1019 608 275 439 133 491 1012 677 137 932 477 644 881 383 581 284 139 321 1041 589 936 634 145 263 902 13 423 312 451 565 593 131 498 610 976 100 608 527 211 264 82 982 141 603 1042 288 32 363 741 506 70 124 938 790 657 486 644 622 544 938 934 407 673 16 394 1017 551 696 421 767 566 519 236 467 450 556 290 864 568 879 338 730 731 97 636 282 384 812 265 354 694 108 211 902 225 868 603 315 290 4…
Output: NO

Example 3:

Input: 222 600 38 86 84 181 63 144 139 222 105 166 48 165 18 3 209 37 119 109 126 109 31 90 114 156 191 123 9 216 45 69 127 44 148 174 216 213 70 206 117 45 48 148 12 194 219 67 28 158 40 99 117 12 153 210 134 120 171 129 140 94 102 97 55 178 23 46 1 45 213 73 222 47 114 36 19 41 135 52 27 62 164 160 114 222 50 124 57 43 172 104 58 94 128 111 132 70 171 55 37 115 70 189 187 100 179 46 31 164 66 215 70 28 83 137 216 100 158 141 27 66 177 200 53 111 158 40 62 79 69 18 16 159 82 123 206 121 77 35 133 92 69 12 214 65 184 75 19 64 97 101 198 50 219 158 170 82 43 122 22 106 163 52 94 85 43 5 101 184 7 150 123 127 146 53 146 107 54 78 189 188 208 136 133 138 87 38 195 45 71 192 2 94 195 77 11 112 60 129 16 136 196 155 186 108 61 137 177 1 34 47 101 194 140 57 105 24 38 45 207 148 86 202 184 58 196 148 5…
Output: YES

Constraints:

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

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