CT44644

Iker's routes Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Iker inherited the gallery at the obsidian flows of Blackglass along with its curious bookkeeping system for routes. Time to make sense of it. 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 <= 2135; 0 <= m <= 2135.

Example 1:

Input: 646 234 83 255 619 297 150 609 586 1 479 551 337 1 7 104 164 293 581 36 96 572 73 377 267 75 567 43 262 171 603 496 165 608 317 575 55 365 429 89 405 228 430 521 352 351 563 416 507 463 83 219 346 323 600 423 263 411 250 455 35 230 427 361 484 408 136 475 228 517 518 367 541 367 556 80 455 487 412 335 213 249 166 191 482 284 587 406 193 26 443 558 171 123 584 125 323 133 492 153 128 237 409 206 372 532 31 454 228 122 133 597 141 21 310 449 298 114 91 584 22 338 556 81 383 262 13 570 63 445 26 84 499 487 264 280 499 339 542 596 260 169 463 482 519 630 161 74 179 592 3 595 224 537 489 256 569 455 455 362 381 191 10 148 462 372 610 451 417 457 598 284 201 35 184 143 206 156 122 567 37 365 18 159 517 68 56 631 44 78 167 180 243 367 277 429 356 418 523 251 343 412 203 504 482 590 287 170 308 35…
Output: NO

Example 2:

Input: 409 1692 165 255 65 50 189 186 61 29 387 126 321 185 106 55 96 123 114 3 279 311 70 241 55 275 189 370 299 242 132 242 186 35 369 233 351 231 349 291 57 339 40 359 78 318 177 48 137 379 112 409 69 223 84 78 93 283 199 223 230 298 313 400 1 386 254 285 268 349 68 65 28 212 340 79 386 210 69 17 97 321 42 3 276 107 166 198 58 232 205 186 109 273 321 170 75 375 245 135 159 214 394 311 184 15 99 43 337 361 116 279 159 65 17 400 187 294 264 150 249 295 264 130 336 12 12 70 300 298 74 322 305 6 335 223 142 298 88 245 402 145 21 318 112 356 341 324 383 100 31 151 193 151 164 291 277 129 4 305 282 265 36 209 60 345 344 130 350 293 93 35 148 237 138 297 313 391 6 94 118 14 119 240 311 304 123 376 187 7 347 374 326 358 188 341 271 58 234 99 167 357 367 132 188 279 320 86 372 346 100 54 398 86 261 360…
Output: YES

Example 3:

Input: 1906 2090 157 527 1297 840 429 1329 385 887 358 953 689 397 1904 184 91 722 1127 593 809 1670 354 458 1320 1123 1707 246 355 646 182 1851 203 890 1228 688 678 1798 1044 1303 274 1730 86 163 1345 233 550 796 337 317 362 33 366 1853 1397 1538 1121 1697 1549 1429 1500 433 459 1705 1725 1754 557 828 395 146 802 1165 483 916 402 968 410 193 257 1423 1603 1294 671 755 162 802 1757 1285 261 1080 1436 1455 1805 1453 807 1021 1006 1281 626 1512 1159 1786 652 1459 1715 290 1205 815 1642 757 1015 400 1214 87 1219 1676 695 529 1135 100 1551 335 793 1109 329 528 1671 1275 1268 552 1761 1377 210 1070 10 805 1305 896 1377 1359 282 1248 394 1493 1829 884 1374 884 1503 831 552 756 793 678 1209 951 458 116 1022 183 950 415 1884 754 648 905 1418 529 613 529 1572 324 427 1159 1662 549 1129 1147 1246 1443 1655…
Output: YES

Constraints:

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

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