CT37835

The Umber Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the beacon hill of Lantern Tor. Tina spreads the canals records across the table and picks up a sharp pencil. 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 <= 1825; 0 <= m <= 1825.

Example 1:

Input: 1444 456 376 112 1101 43 173 1431 1051 891 780 278 463 1123 1376 777 454 611 1440 1199 1137 1310 302 394 1086 88 689 276 484 558 1327 759 1434 605 824 43 144 798 1028 97 388 298 588 612 759 697 820 247 1429 529 334 1354 757 838 166 832 577 94 21 719 162 548 241 1165 93 1242 556 301 1181 681 872 174 479 60 441 481 592 985 1319 838 24 318 565 520 1004 10 894 280 679 833 53 243 843 212 652 316 86 1429 858 1440 1008 658 1359 480 1254 635 398 400 296 345 374 699 755 1034 436 578 268 1379 1426 733 459 102 1182 1109 80 1264 1074 198 485 1249 507 698 116 1371 135 1218 398 292 863 246 163 27 749 214 757 396 583 1297 409 1381 598 151 284 908 333 915 1299 1342 917 1031 1075 1035 961 1281 708 820 859 412 577 1339 840 430 439 56 101 964 1386 41 299 836 103 40 852 1282 621 800 484 1288 87 161 677 561 18…
Output: NO

Example 2:

Input: 1403 1258 1296 1279 920 484 13 681 1271 1011 767 55 1174 1128 281 749 772 813 689 323 671 1116 1300 1344 217 1116 69 489 1391 867 383 802 1128 1208 560 538 197 322 658 878 831 1371 801 213 219 1391 342 292 847 33 933 1139 1349 1320 1346 938 1056 465 135 436 225 151 451 1060 593 1336 930 980 849 900 180 95 735 35 1073 848 35 582 1259 655 763 980 526 87 227 488 1259 479 23 564 202 1095 1323 1403 405 1323 589 389 493 436 766 324 197 784 173 302 1182 2 948 1181 226 649 545 1252 359 379 119 343 1331 1181 6 732 115 90 266 321 1204 292 429 659 195 239 51 341 602 566 77 1167 1189 631 721 881 54 1032 550 268 291 138 1348 505 386 1370 1103 856 1384 972 647 1366 1005 904 461 730 213 53 771 149 137 944 1104 1350 712 593 291 1148 1240 1153 996 870 242 1153 544 1000 1302 253 916 424 740 596 414 658 128 …
Output: YES

Example 3:

Input: 505 397 291 309 333 21 238 462 484 319 201 213 74 9 437 157 503 16 132 362 455 326 126 30 94 339 409 195 469 435 204 414 332 460 425 222 243 319 260 452 186 411 80 45 203 489 104 417 85 250 54 270 323 187 158 372 476 104 1 64 166 465 16 57 251 209 186 317 410 18 143 352 143 318 489 62 231 174 390 503 73 422 76 311 81 140 73 475 381 9 346 26 464 339 39 206 86 343 34 148 400 8 352 404 231 395 328 115 242 449 117 196 18 146 150 411 280 142 480 257 84 189 384 268 502 207 479 230 241 133 412 127 197 429 234 199 395 484 158 205 486 14 150 309 34 141 407 65 323 476 477 234 348 380 207 371 334 61 339 187 176 172 183 210 100 419 281 233 211 247 262 158 211 52 193 397 100 473 100 332 92 391 330 309 178 150 313 307 438 377 317 434 186 302 243 144 161 420 438 480 153 176 477 200 6 130 275 340 32 23 34…
Output: NO

Constraints:

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

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