CT37344

Marek's Ledger of routes

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the honeycomb cliffs of Beeswick pays by the answer, and Marek intends to earn it. First: the full register of routes. 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 <= 3896; 0 <= m <= 3896.

Example 1:

Input: 1777 2638 702 727 59 2 1743 1302 364 917 863 950 1298 154 1263 1454 306 140 689 1392 1232 1568 1740 1532 706 566 1745 1544 1538 1463 295 1145 1484 218 1511 1643 889 1596 751 54 527 884 474 576 1486 1470 1714 1295 559 1467 323 456 415 859 1693 1254 355 638 823 1505 533 239 169 1166 1615 1320 1736 508 1116 1716 68 106 299 311 718 462 941 56 1455 289 731 60 1532 610 1610 92 1108 342 264 1188 443 1606 1585 1528 1547 1508 1098 1720 482 839 1710 296 1307 1459 976 993 255 406 815 1445 1698 627 66 1118 420 388 857 491 1608 1221 680 1079 1652 661 1374 1647 394 105 620 1226 724 505 1386 317 1153 722 859 693 1606 228 491 1530 1025 1672 208 781 773 1753 349 620 1280 992 1628 1489 429 985 150 1542 223 954 984 1442 1128 1684 902 5 380 593 1263 1739 1590 1131 442 1312 1580 1089 1027 1649 928 501 1092 146…
Output: YES

Example 2:

Input: 425 1734 158 95 172 245 389 6 127 32 18 355 23 355 383 120 340 90 192 189 425 95 207 393 17 266 109 28 371 194 205 93 105 229 279 194 234 258 51 389 312 362 324 138 168 50 269 32 410 273 162 181 353 179 393 414 56 313 257 375 22 174 346 96 275 240 234 239 146 216 332 148 244 387 247 5 416 92 345 263 327 192 41 373 287 300 144 250 186 48 53 305 158 260 225 409 61 12 193 249 282 263 113 19 164 361 207 146 325 300 359 347 207 57 94 152 232 9 188 165 324 18 109 65 2 258 161 246 185 143 414 269 362 164 176 397 342 256 267 200 338 343 425 283 388 149 165 9 125 38 125 246 89 78 304 295 151 284 107 228 219 308 128 117 415 123 165 215 364 115 331 99 391 198 5 205 353 176 282 38 157 181 245 195 196 351 69 193 157 26 68 95 21 7 183 169 87 349 11 118 307 321 346 46 405 243 386 366 350 64 230 301 173 2…
Output: YES

Example 3:

Input: 1450 162 872 198 57 392 740 1222 1077 901 739 323 1144 686 192 468 386 108 498 1144 820 441 1448 789 988 1397 751 955 1449 401 997 659 627 9 382 455 982 27 478 1108 1389 1156 439 601 643 1312 1010 333 241 579 1054 771 145 676 1193 1255 518 214 597 1040 585 482 771 1130 881 182 1055 918 165 1230 1413 375 1051 368 1014 640 272 1422 583 833 369 687 316 581 221 435 971 429 610 843 1388 1190 759 477 898 1345 1023 350 670 1305 373 512 595 847 599 1355 170 1048 222 1212 926 576 36 58 292 940 510 428 548 178 331 649 902 990 78 500 838 331 187 542 971 637 296 873 604 713 165 71 884 982 1307 890 1254 905 783 775 394 341 200 477 1387 1010 1048 1093 254 288 1021 441 801 34 760 315 82 1045 235 746 988 1154 342 932 1190 832 938 67 1384 1098 325 464 941 1196 310 466 532 1333 468 838 588 411 732 1031 322 …
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Marek's Ledger of routes - MEDIUM Coding Problem | CodeTikki