CT44974

Jeweler's Shimmering Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the alabaster quarry of Whitestone, someone must track the breeding season. This year the task falls to Jeweler, armed only with the bridges register. 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 <= 2327; 0 <= m <= 2327.

Example 1:

Input: 2028 224 1867 299 784 1329 1792 1646 83 804 312 1078 1060 110 112 733 1084 46 1964 597 1591 1599 861 63 1981 1813 1537 328 488 1306 532 1273 968 2012 653 712 584 901 1372 1193 1309 47 821 1406 580 535 1496 340 1835 496 288 458 1190 1347 308 1498 1103 754 1290 1496 705 1141 266 528 636 345 1555 740 1716 757 698 577 1371 1381 480 1633 639 45 1259 442 1592 297 1536 175 187 661 1361 1789 1671 678 77 346 615 1844 1439 1401 51 545 1942 1918 965 1293 288 1375 307 1979 1290 150 830 1578 728 1770 415 1435 1376 25 698 745 1495 408 1430 882 1657 807 213 872 266 1274 697 785 151 1205 1791 211 708 1714 1586 424 170 502 270 38 1637 1737 1688 57 981 204 1650 1890 660 810 309 930 1495 780 280 21 133 1175 997 1538 1128 514 1385 1746 1541 857 924 1051 1541 1128 178 706 1850 1496 1892 263 736 1080 384 226 17…
Output: NO

Example 2:

Input: 433 1459 243 201 402 184 2 407 374 319 28 347 214 144 71 303 110 295 233 47 198 279 421 134 225 282 82 298 364 337 353 76 260 433 68 253 287 248 3 212 344 347 408 88 210 112 62 162 131 412 352 176 277 9 300 335 264 363 58 23 167 217 363 387 17 180 193 284 8 260 217 408 37 118 67 44 154 96 151 1 27 41 5 313 197 278 166 125 51 255 142 96 80 319 244 288 272 106 245 390 209 340 89 161 291 198 98 263 379 243 430 272 229 413 280 85 236 180 363 418 325 222 381 164 306 159 208 168 392 232 66 324 382 274 237 238 254 192 85 169 307 410 82 302 421 55 377 31 235 275 400 78 270 10 296 152 394 304 148 87 5 360 176 378 27 415 294 404 238 199 364 409 71 371 216 391 11 382 324 4 99 305 85 427 367 18 132 36 298 382 297 409 321 232 107 170 278 125 79 171 152 50 207 127 131 195 99 365 207 118 248 63 403 43 34…
Output: YES

Example 3:

Input: 205 866 144 88 8 185 70 203 178 199 144 157 129 125 135 185 11 132 12 45 53 139 155 122 137 33 16 104 54 100 57 48 196 126 42 143 48 89 48 192 37 179 205 91 122 121 60 20 55 15 36 32 131 90 21 145 116 49 156 172 29 66 202 179 110 109 140 188 42 127 97 84 134 117 177 153 16 110 25 86 175 25 157 165 30 166 69 7 87 176 126 167 2 172 111 35 177 24 30 80 156 146 12 96 3 178 15 181 151 36 80 52 95 152 95 130 7 111 131 92 65 150 73 71 162 10 111 153 80 147 115 171 67 193 68 73 24 42 41 19 38 169 19 73 75 12 62 69 73 201 17 198 147 122 76 85 116 37 137 176 199 52 170 25 18 112 14 177 142 16 168 97 123 110 175 81 98 182 199 77 87 137 97 58 101 152 110 68 161 102 167 55 94 173 203 91 36 5 180 100 107 25 178 149 90 185 89 164 25 30 186 101 139 49 148 165 3 118 202 18 102 37 44 200 69 180 158 65 171 2…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jeweler's Shimmering Ledger - MEDIUM Coding Problem | CodeTikki