CT45735

The corridors Circular Route Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Rekha the reckoner watches over the glass towers of Prismhaven's stores of corridors. A careful computation stands between order and chaos. 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 <= 1982; 0 <= m <= 1982.

Example 1:

Input: 1281 273 897 135 286 639 691 75 344 556 971 1071 505 287 196 539 1209 313 133 444 888 1268 333 1173 537 241 684 11 1064 627 391 383 793 1012 638 850 100 963 134 1052 1193 705 1002 295 214 536 347 1110 886 33 408 425 280 1138 866 25 923 755 816 300 1008 291 764 414 1144 1078 35 192 774 1020 1059 121 1182 714 265 565 16 470 92 1096 871 1250 228 25 1078 1089 281 145 499 541 63 1202 1192 707 801 864 679 229 309 336 863 102 1111 752 777 696 227 1212 722 532 1027 497 1158 109 1222 1117 26 1161 699 413 700 660 760 550 544 719 824 128 648 196 796 1146 516 478 315 944 996 532 176 1119 204 1247 387 385 805 1207 347 236 1140 1212 16 992 827 714 749 929 668 728 882 1019 603 646 1211 185 234 769 12 46 938 104 1052 363 1154 389 1026 819 1157 98 1174 329 609 193 488 753 248 1205 341 18 54 736 692 805 496…
Output: NO

Example 2:

Input: 1180 1263 842 476 402 192 890 1153 135 241 347 391 937 880 1126 184 114 927 616 1129 1072 279 376 109 834 17 1054 815 753 878 817 459 322 1086 924 173 571 924 791 1015 225 667 252 720 588 507 526 1091 1132 1063 894 304 241 286 1176 861 105 389 1173 1005 538 574 378 329 193 1108 588 927 842 897 846 713 33 9 361 783 464 558 339 226 426 547 991 711 1158 1126 806 1000 680 424 500 1069 1107 789 1152 578 1018 381 343 595 494 342 864 973 163 746 923 222 1018 302 1055 1168 724 782 1116 148 82 128 459 116 528 291 105 769 413 343 40 153 571 915 183 570 428 907 790 519 455 234 782 122 185 34 1003 35 58 139 603 495 1084 896 706 52 58 12 1152 528 84 1132 394 514 877 452 203 797 504 28 761 931 1059 757 936 168 958 1063 327 1007 681 1027 27 1055 239 609 215 364 954 593 994 701 83 1117 643 543 820 1028 10…
Output: YES

Example 3:

Input: 615 744 373 65 108 429 98 398 151 588 545 91 224 36 193 484 220 450 313 473 234 367 583 309 95 326 527 395 481 24 483 502 460 202 591 393 9 552 255 30 99 374 420 576 36 331 178 559 395 328 151 131 345 225 241 205 114 358 464 42 71 324 349 471 329 240 308 307 277 580 417 223 598 346 594 319 232 203 434 144 201 531 61 150 46 219 4 602 192 194 524 144 261 472 164 531 337 292 270 64 393 542 77 387 135 252 384 19 548 483 27 580 362 328 200 548 439 249 271 180 546 157 465 220 138 293 412 487 178 376 302 145 274 206 243 139 280 583 145 567 7 393 605 184 142 212 133 314 21 334 356 283 606 372 380 577 319 81 347 580 9 110 43 100 388 526 488 211 46 242 71 197 526 153 33 136 368 107 464 429 585 201 153 336 196 259 78 573 385 275 527 196 285 69 332 567 36 481 94 456 474 225 262 54 119 445 360 359 392 …
Output: YES

Constraints:

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

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