CT49790

The Circular Route at Needlepoint

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the pine barrens of Needlepoint pays by the answer, and Leon intends to earn it. First: the full register of roads. 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 <= 1118; 0 <= m <= 1118.

Example 1:

Input: 514 699 328 16 449 112 462 9 313 193 271 414 248 285 443 414 198 502 214 347 233 103 181 490 53 367 315 104 87 414 273 480 267 204 144 178 194 136 443 82 505 455 100 206 3 187 209 329 97 449 322 67 177 500 453 208 362 368 510 23 428 437 208 3 240 169 43 164 194 66 47 445 168 149 9 340 61 226 406 102 492 327 488 510 498 469 292 230 492 43 207 198 239 443 181 42 254 262 359 369 242 163 98 355 55 458 511 173 310 258 164 505 346 344 110 468 493 292 124 339 99 436 381 192 129 345 360 122 45 330 296 499 185 351 255 80 123 11 146 461 91 46 513 496 494 102 335 244 219 425 434 14 475 252 430 418 441 270 166 130 317 278 510 59 512 145 56 230 17 295 51 101 390 182 124 501 346 152 388 513 79 93 97 305 186 138 309 409 30 264 4 255 115 55 396 20 167 469 155 419 361 156 386 118 106 207 486 134 233 13 51 …
Output: YES

Example 2:

Input: 306 1076 156 190 151 250 101 111 53 248 161 28 180 216 10 184 42 183 153 225 173 109 137 239 202 294 112 178 192 203 62 64 6 299 32 45 130 141 209 134 8 191 12 185 221 151 208 148 26 154 261 244 156 102 121 6 58 8 243 195 236 135 187 218 40 11 236 216 132 151 224 228 103 65 86 270 238 292 200 54 19 82 61 222 43 157 261 88 246 147 117 211 8 271 165 190 126 82 177 100 88 4 256 197 281 97 24 102 205 173 65 291 133 119 305 56 43 249 290 46 304 136 210 118 133 142 162 199 133 167 64 210 133 16 119 91 303 240 3 52 153 59 72 122 156 197 204 209 209 207 72 305 268 220 36 4 167 302 95 151 206 52 32 82 300 50 154 15 99 112 73 55 233 31 9 135 267 294 155 98 296 221 177 69 92 64 55 242 197 208 173 163 118 111 192 134 296 7 262 270 208 169 65 198 21 65 175 135 231 295 290 193 138 126 247 16 187 74 274 …
Output: YES

Example 3:

Input: 1114 489 339 83 92 479 178 811 558 472 373 605 349 341 198 650 475 393 473 889 271 1010 68 507 1071 870 548 54 695 1009 530 698 267 1093 385 943 848 572 215 600 944 593 299 745 774 1056 524 554 1029 766 719 359 992 1077 203 153 133 954 266 695 143 81 213 336 383 354 58 980 173 343 646 904 371 210 19 924 701 730 1037 508 933 325 919 339 952 967 320 280 655 928 855 1027 828 1032 915 33 1018 77 108 568 218 395 920 619 472 358 1040 970 144 139 328 691 295 77 680 382 388 953 67 505 331 492 772 426 676 228 624 1036 218 736 735 163 992 1057 141 687 1021 333 541 403 468 316 822 315 848 370 1030 365 410 512 259 684 237 790 168 141 69 646 678 704 893 180 429 1087 205 204 1018 975 1042 185 141 1070 880 863 866 116 463 404 1028 493 1050 454 408 692 850 531 45 375 276 1033 961 594 184 991 830 26 426 58…
Output: NO

Constraints:

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

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