CT42930

The Circular Route at Bramblecourt

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Cora runs the depot at the thorn maze of Bramblecourt. Today the books show a list of tunnels, and the numbers must be worked out before sundown. 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 <= 2197; 0 <= m <= 2197.

Example 1:

Input: 1215 693 914 1172 997 280 1136 698 695 689 1108 784 413 617 68 1111 1100 1022 1046 675 433 436 757 477 1083 465 846 1072 48 38 183 510 676 202 101 233 804 799 29 240 1164 261 162 36 115 184 1180 724 388 2 915 198 18 636 1003 621 945 123 872 727 414 415 224 995 14 529 596 453 1141 1028 841 313 556 1025 532 1097 404 913 767 575 190 802 611 599 560 489 43 1141 41 1122 998 135 279 1188 1181 530 1087 909 899 242 262 170 773 616 73 410 373 1139 1188 57 890 927 477 705 301 308 703 81 572 1104 819 527 306 1127 52 844 11 645 1050 244 1209 541 935 120 188 558 888 26 304 148 143 23 1162 1136 899 717 692 200 60 1097 535 749 677 1059 1188 1049 421 269 326 685 985 652 1120 1099 952 1038 311 140 870 1118 923 139 333 926 939 797 236 689 784 1046 1087 1098 935 152 183 1037 177 163 315 1082 81 696 895 423 4…
Output: NO

Example 2:

Input: 1568 31 819 910 439 648 134 1058 111 1171 1237 335 177 1081 62 938 890 69 275 297 1201 1189 1348 456 810 1096 849 1250 1468 513 1157 1008 1281 394 684 1157 296 1221 486 306 1256 424 545 1434 511 1557 472 53 1049 1185 20 919 1061 907 1191 91 247 1186 321 204 1055 363 484 239
Output: NO

Example 3:

Input: 81 507 50 30 53 7 68 33 18 21 70 68 65 67 62 42 58 1 78 74 3 2 47 81 24 37 13 61 47 26 65 41 42 4 44 40 50 59 44 15 74 43 66 64 56 33 70 53 77 75 58 44 20 56 22 44 16 36 5 12 40 22 34 65 26 2 40 57 46 7 15 9 75 11 55 53 25 58 26 44 40 23 24 57 2 73 33 55 45 51 61 22 56 20 58 71 78 5 25 2 24 9 50 7 65 3 72 62 18 45 31 25 5 76 68 79 20 3 27 72 67 71 22 11 75 14 13 64 17 4 25 47 1 75 24 69 59 42 31 71 81 69 79 76 65 28 31 45 37 28 33 5 25 33 42 76 14 52 6 74 61 11 63 47 5 79 52 77 52 39 79 15 36 35 31 24 24 58 18 3 13 11 50 24 15 77 64 8 8 42 49 18 15 43 33 7 1 73 18 36 71 48 17 38 39 35 14 15 32 67 17 78 23 62 76 74 77 58 33 38 32 76 22 6 2 37 41 54 15 8 21 27 31 74 60 48 28 68 41 67 8 12 61 52 6 14 55 36 24 73 24 35 80 25 56 41 68 51 20 53 24 40 56 5 54 33 33 67 28 37 73 46 28 67 62 19 59 5…
Output: YES

Constraints:

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

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