CT50318

The Beryl Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the thorn maze of Bramblecourt pays by the answer, and Nina intends to earn it. First: the full register of bridges. 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 <= 2346; 0 <= m <= 2346.

Example 1:

Input: 675 357 363 402 624 30 670 50 32 475 207 375 69 629 150 624 503 443 178 558 311 269 303 145 188 638 427 585 531 434 649 646 377 492 329 609 185 140 35 69 390 665 508 256 313 374 370 144 89 346 91 297 580 437 533 557 593 452 244 387 50 512 558 453 491 582 339 250 637 495 427 123 97 642 5 312 554 577 425 568 129 526 62 615 158 43 204 172 615 489 471 219 69 126 327 68 28 94 591 496 64 572 562 441 149 451 15 446 492 158 63 351 621 243 541 27 645 18 163 126 513 508 593 409 191 343 81 336 210 82 635 671 134 572 109 316 439 539 51 135 231 15 85 449 459 380 194 31 447 351 323 408 192 391 569 658 555 574 109 118 208 97 249 530 53 177 204 300 50 495 598 624 460 568 384 468 157 572 32 325 215 57 10 35 424 195 671 62 93 186 137 510 410 324 360 385 146 189 95 141 349 247 452 659 482 604 389 167 37 381 …
Output: YES

Example 2:

Input: 2060 1292 895 1792 568 257 896 462 1488 1291 1989 1715 1918 1211 963 1081 1596 625 1870 161 327 1378 1428 1829 267 247 1172 1435 1249 1912 1893 2041 1838 1761 1209 1712 117 1882 226 1061 729 2028 404 228 731 1767 282 1990 404 278 1071 1507 1248 871 1059 858 1023 375 782 858 1392 726 1393 730 593 507 346 328 1368 65 922 1203 433 1598 922 1664 1250 1029 1514 1870 1671 518 4 1445 808 1203 695 1526 1241 1717 210 1590 1573 1699 1058 1601 1366 1122 1411 717 1719 1792 384 353 1663 1005 38 1991 1058 444 892 987 1229 526 1352 1387 201 364 1553 1270 1273 933 943 352 671 202 345 480 1556 2025 884 1811 751 218 875 1674 1304 830 259 1441 137 1299 174 482 1300 761 560 1477 1280 747 823 703 1795 1332 562 1383 584 1212 1859 673 1991 35 1167 802 369 57 307 1334 80 256 1710 1701 1431 1268 884 411 1900 1758 …
Output: NO

Example 3:

Input: 1522 1874 1221 754 1239 487 351 1036 1097 794 1478 635 1223 688 153 685 817 479 105 1294 284 1088 121 495 1186 723 1491 888 233 384 721 1383 918 1129 405 976 489 11 1516 349 752 933 659 586 506 786 783 1488 336 1120 466 49 115 12 1181 1104 1186 907 1193 234 1146 1050 390 846 495 1278 1466 1257 297 1217 601 122 1467 871 742 231 1480 824 1252 833 981 480 554 48 588 708 571 845 1117 606 465 565 147 631 1038 1177 1180 870 827 101 1031 482 718 1065 864 1103 546 1433 538 684 839 612 1020 1369 490 608 259 1475 1310 241 1167 440 1119 957 1044 677 403 64 1434 199 950 490 170 2 298 79 1108 1059 679 871 1202 1403 448 1104 102 1111 451 1419 225 923 1499 372 248 268 1305 1482 213 1231 554 663 862 13 1166 934 1010 1050 1087 304 43 1491 790 359 488 1271 206 443 893 1515 1041 362 346 429 1300 1075 1423 82…
Output: YES

Constraints:

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

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