CT49345

Nyssa and the Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the snowberry thicket of Winterholt as Nyssa unrolls the day's manifest of routes. The tally will decide the next shipment. 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 <= 1317; 0 <= m <= 1317.

Example 1:

Input: 362 670 307 2 323 159 171 93 173 202 79 206 274 164 169 298 222 169 26 61 354 108 150 214 285 72 17 208 334 130 137 231 59 119 337 322 83 247 84 360 154 172 31 225 283 276 139 46 39 179 69 319 221 151 311 229 122 1 138 252 183 83 329 29 275 71 225 215 140 120 26 135 122 102 136 227 114 200 7 335 184 307 136 36 162 255 154 48 204 254 188 266 52 220 155 264 248 253 273 291 274 53 176 81 224 337 357 323 97 98 130 78 130 127 276 312 77 253 340 52 107 91 47 196 131 153 70 13 71 109 27 306 14 129 114 24 10 217 147 266 244 119 83 191 62 349 120 150 214 212 140 116 224 36 179 296 328 54 300 183 77 267 156 149 88 262 47 70 132 224 14 42 203 272 319 240 200 330 280 24 207 349 75 285 63 14 341 45 187 44 322 74 294 65 78 353 136 68 136 297 97 203 316 263 66 253 53 128 52 35 325 334 229 323 151 233 193…
Output: YES

Example 2:

Input: 781 711 492 147 3 150 775 76 566 537 152 663 677 150 551 35 386 265 142 407 69 650 480 469 148 215 377 574 401 629 763 38 485 575 777 579 186 588 656 412 695 438 425 149 424 6 758 206 630 143 409 551 631 698 553 697 656 181 328 139 373 733 280 588 237 524 168 81 762 524 99 779 339 488 650 165 505 652 207 471 489 439 252 482 17 564 630 351 467 105 233 573 634 208 208 690 456 377 431 207 183 198 755 65 255 180 139 645 738 398 656 487 426 475 276 298 334 688 526 471 202 269 345 517 588 139 712 307 293 604 762 628 129 523 340 653 70 330 697 432 627 487 192 272 770 378 475 443 509 458 41 301 97 144 267 769 355 107 188 74 127 606 513 216 109 169 721 142 456 37 443 771 222 495 613 399 615 203 518 301 664 351 165 679 580 560 295 136 73 198 137 272 249 367 147 531 532 486 746 757 407 299 402 543 40…
Output: NO

Example 3:

Input: 418 939 86 314 333 51 122 374 405 187 47 352 332 305 287 396 272 6 313 72 243 47 252 129 83 191 161 168 414 145 309 51 31 2 111 231 226 36 87 250 4 287 407 230 252 375 234 35 72 205 160 358 221 105 395 119 110 344 355 97 275 115 338 223 241 347 86 228 1 132 383 226 244 319 90 140 218 256 147 155 51 134 354 392 48 64 142 359 79 136 94 322 58 88 412 303 322 114 363 43 365 230 364 137 4 163 84 231 284 151 5 147 171 271 146 172 303 11 338 34 377 170 400 78 291 382 107 119 348 383 259 395 411 268 24 65 51 111 207 334 222 165 154 409 175 32 244 300 262 163 343 189 322 151 92 332 93 100 174 182 33 100 189 324 20 276 247 230 351 116 407 76 294 285 293 338 392 180 300 163 346 87 374 282 193 167 244 181 247 345 80 195 359 257 366 385 124 309 30 403 189 18 306 277 226 39 164 45 397 48 182 66 378 63 2…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nyssa and the Circular Route - MEDIUM Coding Problem | CodeTikki