CT46475

The roads Circular Route Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the ribbon falls of Cascade Vale. Paige spreads the roads records across the table and picks up a sharp pencil. 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 <= 3251; 0 <= m <= 3251.

Example 1:

Input: 2925 3115 1268 1521 42 167 2441 886 202 1173 2564 1644 697 590 1552 2920 2238 2106 378 2387 2174 2181 2156 2916 2480 93 1119 1166 645 99 1392 1643 311 2191 1268 1398 1541 1911 1350 103 2217 2435 624 2005 2646 1908 1736 235 2571 1374 2081 1727 166 1982 2000 104 212 2564 2123 1610 1548 2511 258 1498 928 222 1515 2157 1865 599 1148 489 2540 800 806 2518 1017 1176 433 1910 1616 317 975 613 989 1545 2710 307 2851 1475 2522 2493 874 2284 2149 935 223 2079 522 1794 1947 2114 186 1166 937 1484 682 125 1932 2629 1315 2595 1186 2267 1429 2874 919 624 2063 558 2892 1855 345 2702 188 2312 1180 100 2869 490 2379 808 1283 1061 868 1581 2353 1513 1265 889 531 184 2386 2684 1302 940 1439 289 1476 2391 2583 2172 2713 1490 401 1416 655 2717 2749 2420 2871 950 1500 2017 1598 2470 1763 1652 1092 1614 889 1539…
Output: YES

Example 2:

Input: 296 1223 213 159 241 78 17 49 170 133 232 252 238 60 105 89 222 268 48 64 45 294 90 212 53 62 256 65 23 175 101 192 238 155 239 23 80 101 205 196 34 84 273 177 36 110 14 186 165 253 244 251 30 188 22 202 11 254 48 274 128 56 17 264 64 56 99 91 32 122 164 225 7 245 123 164 105 157 85 213 197 161 182 124 77 121 23 2 279 116 188 111 87 195 208 109 269 129 281 22 239 293 173 137 166 290 173 100 190 138 140 160 204 181 122 245 169 220 117 272 295 237 195 55 6 257 150 173 251 60 18 88 225 35 228 240 30 72 207 257 31 120 133 35 34 242 26 216 101 203 109 81 86 84 266 153 107 288 80 82 6 275 227 155 177 287 94 241 13 8 242 232 93 86 144 175 14 219 96 184 32 187 258 35 271 35 205 206 262 58 43 165 127 254 29 130 15 44 118 149 197 183 98 228 18 291 26 121 15 295 95 79 76 52 156 85 105 191 130 223 155…
Output: YES

Example 3:

Input: 832 256 562 411 602 683 576 536 409 746 566 244 481 791 748 8 802 99 622 797 344 200 606 239 481 525 578 387 627 361 238 766 754 321 126 16 91 606 691 217 709 105 580 14 731 623 144 259 783 363 187 162 792 117 647 42 129 287 485 205 560 384 85 651 503 27 159 118 116 365 474 633 290 265 587 233 109 571 273 428 530 374 821 768 223 512 5 431 410 372 110 663 699 27 290 767 667 100 271 760 332 824 77 55 733 425 71 50 321 674 719 556 250 770 383 556 140 385 134 364 224 72 232 290 628 721 19 23 259 752 217 112 215 323 131 461 333 148 598 538 732 257 752 364 549 146 473 132 446 287 491 470 226 554 130 521 110 84 14 709 650 509 183 697 790 646 574 773 173 26 573 276 473 655 800 609 552 125 544 516 775 792 573 157 366 495 549 276 522 475 408 427 260 506 292 195 767 484 189 278 90 378 421 519 410 89 …
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.