CT51014

Brevin and the Golden corridors

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Brevin runs the stall at the savanna camp of Amberplain. Today the books show a list of corridors, 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 <= 2256; 0 <= m <= 2256.

Example 1:

Input: 1212 1618 163 730 839 698 431 902 1139 421 703 699 848 1114 227 1175 1022 739 294 331 660 42 1103 767 979 870 290 1031 33 288 641 399 417 404 334 61 184 508 285 417 67 1090 361 250 789 276 706 967 681 304 807 363 982 57 723 401 347 272 818 387 357 94 545 744 1069 465 97 268 966 1118 7 166 1183 636 737 757 845 433 400 117 452 76 273 314 213 645 234 1201 412 78 358 528 610 625 954 865 1145 1160 116 189 864 658 769 290 115 1121 468 235 1049 669 989 1081 1132 844 807 188 932 703 1049 912 623 375 1162 657 1191 749 850 194 1063 963 1210 381 50 205 365 196 362 809 642 450 449 928 923 1191 639 706 392 1206 432 9 247 933 56 434 853 1016 357 661 1155 503 977 592 955 468 719 942 126 518 85 983 752 1062 605 104 100 1080 31 621 563 331 241 148 762 411 311 978 968 476 664 79 784 1094 142 440 565 749 4 2…
Output: YES

Example 2:

Input: 341 1813 219 294 49 185 201 191 170 244 319 193 114 76 49 197 21 295 114 254 52 114 250 133 334 324 168 227 94 32 34 228 228 273 174 15 292 280 180 42 286 159 22 265 163 118 245 80 117 222 223 123 288 120 166 57 15 106 204 239 87 136 300 19 169 188 243 293 224 83 175 141 123 333 76 95 194 189 319 176 146 138 306 206 163 73 167 251 54 80 160 332 80 296 320 278 16 210 324 116 337 297 333 192 58 79 329 43 141 244 181 293 316 205 182 208 283 315 132 314 247 30 262 269 148 233 91 134 295 114 274 163 288 280 50 84 87 33 192 143 323 221 313 251 141 104 251 283 224 271 14 128 295 142 132 53 196 14 291 182 237 159 159 120 319 235 249 53 128 221 233 201 33 292 81 60 9 314 249 158 11 81 132 49 145 304 55 221 173 319 137 255 39 127 325 117 248 234 62 54 282 65 153 305 175 80 280 126 139 185 341 278 33…
Output: YES

Example 3:

Input: 2115 2049 100 766 661 89 516 689 1567 1223 470 709 1551 1014 1563 1880 1788 1765 658 936 1016 1437 152 1558 579 1564 1135 1607 133 1045 1640 231 683 591 2098 1541 1755 891 426 1815 459 775 1923 1343 42 681 1809 287 1073 1420 1182 722 398 722 1911 1504 1942 2009 315 637 1936 1209 1265 74 1768 1933 486 625 65 987 2093 194 873 181 453 1484 1393 1682 1293 1117 1570 715 1136 2037 655 226 1705 593 321 37 1562 536 657 874 615 1424 1677 345 241 1680 942 1383 1344 1660 439 1301 2029 1582 1407 1835 1273 1463 262 1384 1912 625 864 90 635 977 58 1189 1826 489 1734 735 1685 2097 1634 626 1875 1219 1484 1213 1214 369 251 211 1292 1053 770 476 488 69 2051 356 338 592 779 336 1640 844 370 290 1514 1042 1567 1275 1854 2076 1886 431 1243 635 1608 608 1692 348 854 1379 453 1541 242 1890 1933 2049 1250 1780 1…
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Brevin and the Golden corridors - MEDIUM Coding Problem | CodeTikki