CT55238

The Teal Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the honey farms of Buzzwell, someone must audit the season's records. This year the task falls to Farhan, armed only with the corridors register. 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 <= 3675; 0 <= m <= 3675.

Example 1:

Input: 1288 1382 1143 1263 884 554 273 1186 36 773 1025 281 243 967 974 225 685 717 381 623 93 96 625 68 800 401 362 366 265 868 1001 509 674 958 42 306 420 1125 46 836 631 759 589 934 80 776 476 862 319 988 146 798 805 957 907 755 314 76 907 265 516 989 103 149 430 895 924 450 1031 795 1192 648 292 875 944 1153 202 499 554 624 308 889 126 1098 1114 496 1097 437 1042 99 18 1089 778 107 779 145 711 96 739 1067 713 252 1015 496 1082 476 853 1076 735 310 586 901 1169 420 1020 853 1215 859 760 907 1278 134 1028 696 325 535 420 205 28 139 1250 347 351 1208 1068 120 813 365 653 422 500 1066 1141 422 991 739 134 1069 1190 950 181 1053 1261 734 416 72 1052 409 295 406 232 158 982 505 888 507 903 1042 342 203 621 963 45 1090 905 39 45 1021 927 672 1154 193 273 34 1130 530 370 495 48 380 693 654 719 176 32…
Output: YES

Example 2:

Input: 504 3513 123 16 191 38 241 494 49 206 42 289 459 330 19 328 494 387 276 480 182 245 278 172 36 58 19 67 64 163 10 257 47 116 4 353 257 102 272 472 278 408 273 5 442 429 445 440 91 186 99 166 324 356 131 483 160 17 291 45 109 18 230 273 201 441 82 346 182 369 132 101 150 101 154 163 1 390 262 380 232 150 53 422 301 224 368 401 504 479 204 276 21 391 449 343 199 347 20 435 431 30 182 99 501 57 151 350 329 200 349 274 404 493 64 149 480 259 408 110 76 239 79 327 465 430 246 379 264 349 407 324 495 477 200 147 260 262 404 227 431 417 4 428 143 324 356 362 432 444 120 335 214 117 20 348 140 20 397 341 407 46 382 149 42 323 194 141 472 498 231 175 373 244 336 36 15 463 436 289 441 334 377 387 112 101 318 202 307 105 381 113 194 207 145 444 52 205 380 60 203 436 247 175 171 388 275 389 242 118 47…
Output: YES

Example 3:

Input: 1269 2930 261 450 73 1213 227 623 264 1193 1202 960 1177 3 495 950 215 907 285 581 969 805 1010 897 84 856 199 924 61 941 1084 737 479 542 293 170 1014 97 290 531 1038 959 1238 975 636 340 600 296 423 29 688 87 988 1029 1164 256 79 578 1121 671 449 969 602 555 1169 528 727 241 376 837 677 335 735 341 1181 664 752 121 345 1128 1147 1073 518 932 1045 240 759 414 1204 749 403 801 985 495 238 664 132 202 605 819 44 971 517 892 23 460 542 1088 436 759 1264 731 935 1167 973 1036 1262 800 1089 1019 1217 784 106 1245 1201 407 767 951 646 887 764 347 705 702 196 839 1039 830 1050 1149 85 953 482 722 668 941 1178 1133 1018 1165 127 446 841 126 287 828 742 926 106 469 479 620 961 563 712 578 286 1035 781 156 370 996 367 551 953 403 975 88 570 1055 282 91 938 806 54 867 840 824 521 40 1082 1223 362 43…
Output: YES

Constraints:

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

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