diff --git a/GG2DP5_hf01.zip b/GG2DP5_hf01.zip index a14b0f470ddc9df10f50ec63dec4325686f6507d..25b7423e61914151b2e2538fbd2e2ff232668e39 100644 Binary files a/GG2DP5_hf01.zip and b/GG2DP5_hf01.zip differ diff --git a/input4 b/input4 new file mode 100644 index 0000000000000000000000000000000000000000..7a12b0ff9eb59d6ece003952836ec69b93839429 --- /dev/null +++ b/input4 @@ -0,0 +1,913 @@ +160 +1810 +2907 + +1805 59 +1783 68 +7 1781 +1808 53 +1796 19 +1808 1 +1788 1 +47 1784 +1782 65 +5 1804 +1785 53 +8 1787 +1791 61 +20 1795 +65 1781 +1808 14 +50 1808 +1792 36 +1797 32 +1790 37 +1792 35 +38 1801 +1787 63 +1805 79 +1791 71 +10 1786 +9 1780 +1790 39 +1788 25 +1799 33 +1794 75 +1785 77 +4 1794 +1790 2 +21 1792 +1801 49 +51 1795 +1805 56 +35 1790 +24 1804 +22 1787 +32 1802 +7 1794 +58 1786 +75 1804 +1803 29 +70 1809 +1798 12 +48 1788 +66 1801 +2 1780 +6 1809 +1799 14 +1784 67 +1807 56 +9 1808 +17 1794 +1793 19 +35 1798 +1796 41 +10 1788 +1807 15 +1809 46 +25 1792 +35 1787 +61 1798 +1782 71 +1782 68 +1 1791 +1805 2 +1801 14 +1789 48 +1780 16 +1805 10 +1801 52 +1784 63 +1792 67 +46 1808 +4 1809 +41 1802 +1803 79 +1798 1 +63 1799 +49 1789 +1808 48 +40 1786 +1782 13 +5 1793 +1787 78 +29 1781 +55 1796 +1802 39 +36 1803 +1792 38 +27 1788 +39 1780 +79 1801 +36 1791 +1781 19 +21 1806 +1784 31 +66 1783 +1807 29 +26 1786 +1799 17 +12 1799 +1784 0 +1788 53 +27 1801 +79 1786 +1784 57 +35 1780 +6 1797 +1793 49 +64 1786 +41 1803 +1786 8 +4 1785 +75 1796 +17 1785 +1799 58 +1790 24 +25 1809 +78 1804 +1803 58 +1781 16 +1799 32 +45 1780 +1784 38 +1783 23 +64 1792 +1796 2 +1790 59 +32 1794 +49 1797 +1789 15 +1788 31 +1800 71 +1809 64 +1785 12 +67 1807 +49 1799 +43 1782 +11 1805 +1789 8 +77 1796 +1791 78 +1801 42 +49 1800 +1783 24 +1796 65 +0 1807 +17 1786 +1788 57 +1806 46 +47 1805 +1795 69 +79 1784 +1795 27 +3 1780 + +46 -56 +-11 -58 +-41 81 +85 96 +-24 98 +23 -72 +77 -11 +-78 -100 +-82 67 +-91 -14 +-24 88 +47 72 +-14 -90 +-19 -53 +66 -26 +-6 -46 +22 -34 +85 97 +-33 -38 +-16 -84 +3 91 +-91 66 +1 37 +58 -61 +-7 58 +37 -48 +53 -70 +23 0 +-5 39 +-21 58 +37 -96 +16 96 +-42 89 +52 90 +-39 -82 +-90 -55 +-98 -93 +-47 22 +91 57 +0 -100 +55 6 +79 -90 +-20 -42 +88 6 +94 -42 +-17 11 +31 12 +-64 -18 +83 46 +33 4 +-26 -51 +-64 -66 +-51 23 +47 -7 +-15 74 +26 75 +-14 -61 +-69 -7 +-58 -41 +55 -100 +-86 -55 +87 -94 +-9 -3 +-4 88 +60 -37 +73 -49 +53 -61 +-95 25 +-12 18 +-17 67 +-64 -89 +-76 59 +90 98 +-29 -43 +87 -26 +-68 -64 +-92 74 +-81 -27 +-53 -72 +-13 58 +-108 485 +154 344 +61 503 +-177 469 +152 269 +56 229 +-28 485 +-27 313 +137 409 +145 248 +-121 319 +71 407 +-138 410 +101 588 +-62 592 +-193 410 +-100 595 +92 295 +-140 239 +-134 208 +-23 366 +-64 455 +95 508 +93 575 +-97 255 +96 497 +-199 504 +11 568 +51 301 +-198 325 +180 439 +131 454 +25 505 +-42 333 +-95 309 +19 479 +39 515 +-172 313 +11 549 +-26 339 +29 429 +96 457 +-43 361 +-154 468 +-103 280 +-174 338 +71 509 +140 444 +-110 535 +34 590 +73 383 +-158 240 +7 333 +8 549 +113 590 +-108 365 +117 280 +2 203 +-23 458 +105 417 +119 475 +200 295 +51 572 +41 297 +60 461 +-177 366 +-57 584 +-63 342 +134 570 +3 590 +61 553 +-21 271 +-107 432 +-92 244 +155 575 +-84 399 +-164 259 +-158 518 +3 208 +87 296 +-108 360 +155 245 +37 270 +114 310 +-154 444 +-47 238 +24 385 +-54 285 +-102 249 +169 512 +105 351 +125 339 +-175 496 +109 559 +120 379 +-196 543 +146 587 +67 491 +-38 369 +-57 310 +144 422 +4 226 +-26 266 +-7 388 +-71 313 +138 521 +157 544 +-110 404 +119 353 +85 564 +-188 241 +-130 314 +1 243 +-7 406 +-189 334 +191 437 +-144 445 +168 246 +-3 210 +165 566 +-116 340 +98 380 +4 424 +145 364 +-116 586 +-1 569 +-12 395 +-87 575 +-182 583 +-56 405 +-31 369 +145 444 +-74 384 +-22 544 +-194 271 +-14 359 +79 337 +17 449 +66 481 +-168 379 +66 569 +-33 328 +-88 515 +-175 278 +-18 532 +-65 415 +-172 322 +-157 560 +165 388 +-111 440 +-18 462 +197 350 +-132 257 +138 481 +-169 441 +109 322 +-48 261 +20 230 +61 313 +111 458 +-34 245 +-111 265 +-12 364 +46 290 +-66 378 +119 516 +132 570 +-57 587 +-101 217 +61 300 +-10 251 +160 491 +-116 420 +13 240 +195 481 +40 432 +95 585 +-24 459 +138 346 +137 320 +81 244 +-121 523 +-116 255 +116 215 +194 272 +136 228 +60 303 +-143 489 +189 522 +-23 223 +31 409 +-75 352 +31 284 +-35 586 +-88 358 +116 591 +110 547 +-95 322 +-53 265 +-33 504 +-119 371 +-161 512 +128 452 +-122 286 +27 305 +10 217 +141 204 +-19 339 +83 219 +107 278 +52 545 +-91 388 +136 466 +-111 599 +185 581 +52 234 +141 246 +137 304 +-67 324 +-100 491 +30 350 +-149 449 +-36 374 +51 433 +152 331 +101 477 +106 540 +95 347 +198 335 +-81 567 +-78 236 +-3 303 +-118 311 +-150 314 +-86 419 +5 315 +87 496 +-173 324 +-83 556 +-107 220 +-111 321 +61 251 +194 568 +191 218 +-95 333 +-191 374 +-40 357 +-38 375 +-85 367 +119 533 +160 599 +-128 271 +114 534 +120 403 +-183 423 +139 359 +-17 564 +-156 456 +-118 423 +10 474 +101 410 +-63 230 +195 348 +-35 562 +-131 583 +198 585 +135 462 +61 206 +-170 208 +-79 559 +6 470 +-168 448 +-90 580 +76 599 +-84 371 +-78 268 +196 408 +119 441 +-79 280 +-38 217 +-43 314 +-57 370 +11 210 +-22 535 +131 301 +-145 316 +-31 436 +35 515 +43 472 +-50 566 +168 521 +32 432 +-10 556 +-91 261 +-167 448 +-182 396 +196 539 +-142 266 +20 586 +-114 295 +-81 383 +-116 362 +-128 242 +-108 291 +-49 287 +-98 268 +-9 465 +-136 486 +58 379 +-89 351 +158 309 +19 219 +-26 548 +127 451 +196 394 +-178 380 +-61 569 +-144 456 +28 281 +60 565 +-112 321 +-80 286 +-192 378 +-52 509 +58 486 +-168 327 +-20 244 +33 252 +-146 501 +148 328 +74 265 +30 480 +132 570 +-106 251 +-21 311 +-117 234 +88 532 +33 334 +-183 304 +-139 444 +-185 318 +-122 216 +-137 287 +-118 294 +174 533 +-198 586 +-87 437 +-79 265 +85 263 +-197 437 +28 228 +113 307 +-142 348 +178 269 +104 236 +129 397 +141 247 +-117 223 +-173 552 +99 337 +-151 385 +-90 410 +166 323 +13 493 +98 375 +-89 295 +-71 352 +193 216 +-99 320 +-173 272 +130 291 +-152 546 +-191 546 +200 372 +-25 270 +-60 342 +112 573 +-195 336 +-85 438 +-79 533 +142 465 +-65 376 +-20 589 +129 440 +168 581 +155 508 +-76 375 +79 325 +123 358 +-186 229 +192 337 +-9 287 +21 484 +-48 333 +-89 334 +183 528 +-189 510 +187 231 +-1 282 +199 299 +33 485 +71 489 +34 596 +-148 478 +-111 215 +197 600 +-113 237 +169 594 +-53 358 +130 265 +124 338 +-142 488 +29 380 +101 235 +-35 331 +-188 423 +-127 419 +128 223 +-153 370 +-82 494 +189 317 +22 544 +-93 597 +-193 318 +154 270 +135 276 +-160 235 +-164 404 +-153 534 +-166 250 +-117 556 +108 261 +-151 238 +168 234 +-199 275 +-36 296 +-111 419 +-140 320 +37 339 +-46 273 +12 494 +-46 322 +185 305 +185 251 +136 226 +-144 505 +-15 369 +-137 464 +129 224 +170 436 +76 214 +-16 301 +107 576 +-152 426 +-67 509 +170 256 +179 441 +101 468 +94 446 +10 352 +123 423 +169 342 +97 549 +-191 233 +-165 230 +-194 599 +-83 363 +-38 244 +-92 307 +68 310 +-158 568 +-181 548 +-72 252 +43 318 +-25 358 +-182 402 +164 406 +177 204 +27 326 +-101 401 +172 531 +-54 229 +-18 440 +115 445 +62 461 +143 306 +-113 326 +149 443 +50 493 +-168 386 +-125 567 +161 591 +28 339 +-12 289 +-102 421 +130 447 +-36 458 +194 301 +-130 406 +124 232 +-57 218 +-93 351 +197 373 +-171 333 +-191 521 +153 248 +147 551 +-27 210 +129 395 +-158 353 +163 212 +118 244 +24 228 +77 260 +-27 220 +-44 590 +-74 228 +-163 497 +114 480 +17 317 +17 220 +71 488 +46 522 +137 543 +24 500 +106 477 +-151 286 +143 303 +-29 495 +-143 336 +-100 581 +61 470 +37 368 +-23 270 +64 509 +-128 326 +-3 322 +50 555 +-126 299 +-162 587 +104 580 +-2 282 +100 305 +103 360 +-165 444 +150 559 +49 594 +-200 406 +18 283 +-128 310 +9 438 +-158 311 +-93 569 +65 328 +-10 582 +-43 265 +-192 478 +11 203 +-81 480 +-70 405 +-152 537 +150 303 +176 297 +-109 599 +7 529 +88 443 +-49 525 +-70 216 +50 383 +-89 454 +51 535 +-83 320 +151 600 +191 510 +107 316 +-155 209 +-123 230 +-111 380 +-154 537 +-165 413 +186 474 +160 274 +-67 594 +-129 420 +-98 546 +-107 348 +-32 599 +-181 375 +-50 256 +-47 428 +-133 266 +6 271 +51 514 +174 386 +-82 294 +-34 332 +145 477 +190 436 +-98 212 +186 593 +-122 258 +36 500 +-103 237 +1 261 +-130 321 +147 339 +127 446 +20 321 +-162 354 +-156 393 +101 273 +-32 227 +21 430 +194 369 +-131 375 +-40 315 +35 593 +-81 302 +-65 567 +-89 584 +43 428 +-160 254 +-109 555 +-63 248 +28 290 +5 588 +-193 515 +-133 280 +-14 584 +-103 521 +-118 343 +116 282 +-85 386 +-183 265 +159 554 +-190 419 +127 446 +145 343 +190 232 +126 510 +58 370 +-124 374 +7 455 +-178 554 +-148 379 +-106 367 +12 344 +-174 471 +138 491 +-83 395 +118 227 +49 528 +127 507 +112 425 +-153 280 +-185 419 +120 391 +-83 481 +-112 548 +-99 406 +131 249 +121 382 +149 265 +-185 293 +52 489 +-128 298 +159 409 +-14 42 \ No newline at end of file diff --git a/mi_GG2DP5_hf1.py b/mi_GG2DP5_hf1.py index d43e5f5a7db761b7da5fec546c3a01f3886e1f66..7d2962703d4a15683d3560eb260cba8e293a713e 100644 --- a/mi_GG2DP5_hf1.py +++ b/mi_GG2DP5_hf1.py @@ -27,38 +27,44 @@ def dijkstra(a, b): if(a == b): # Ekkor elertuk a keresett pontot calculated_lengths.append(distance[b]) + #print("*** debug: kiszamoltuk a legrovidebb utat" , file=sys.stderr) return for i in range(0, len(route_between_points), 2): # iteralni a route_between_points-on, hogy az == e a meghivottal es kiszamolni a szomszedokhoz tartozo utat, ami esetleg legrovidebb lehet if(route_between_points[i] == a ): length = calc_route_length(a, route_between_points[i+1]) - if(distance[route_between_points[i+1]] == math.inf): - print("*** debug: " + str(distance[a]), file=sys.stderr) - distance[route_between_points[i+1]] == length + distance[a] + if(distance[route_between_points[i+1]] == None): + distance[route_between_points[i+1]] = length + distance[a] + #print("*** debug: distance = " + str(distance[route_between_points[i+1]]), file=sys.stderr) continue - if(length < distance[a] + distance[route_between_points[i+1]]): # ha kisebb az eddig tudott utvonalnal a most talalt, akkor cserelje ki arra + if(length + distance[a] < distance[route_between_points[i+1]]): # ha kisebb az eddig tudott utvonalnal a most talalt, akkor cserelje ki arra distance[route_between_points[i+1]] = length + distance[a] if(route_between_points[i+1] == a ): length = calc_route_length(a, route_between_points[i]) - if(distance[route_between_points[i]] == math.inf): - distance[route_between_points[i]] == length + distance[a] + if(distance[route_between_points[i]] == None): + distance[route_between_points[i]] = length + distance[a] continue if( length + distance[a] < distance[route_between_points[i]]): - distance[route_between_points[i]] == length + distance[a] + distance[route_between_points[i]] = length + distance[a] minimum_distance = math.inf corresponding_point = None cntr = 0 - for i in range(len(seen)): - if(seen[i] == 0 and distance[i] != math.inf): #Meghivni ra a dijkstra algoritmust rekurzivan, ha mar szamoltuk, de ne jartunk meg benne + i = 0 + #print("*** debug: " + str(len(seen)), file=sys.stderr) + for i in range(0, len(seen), 1): + #print("*** debug: " + str(distance[i]), file=sys.stderr) + #print("*** debug: " + str(seen[i]), file=sys.stderr) + #print("*** /debug ******* ", file=sys.stderr) + if(seen[i] == 0 and (distance[i] != None)): #Meghivni ra a dijkstra algoritmust rekurzivan, ha mar szamoltuk, de ne jartunk meg benne cntr += 1 - print("*** debug: talalt pontot amiben meg nem volt", file=sys.stderr) + #print("*** debug: talalt pontot amiben meg nem volt", file=sys.stderr) if(distance[i] < minimum_distance): # Es legkisebb a tavolsaga eddig minimum_distance = distance[i] corresponding_point = i @@ -79,19 +85,19 @@ def route_search(): if(i == route_to_calc[x]): distance.append(0) else: - distance.append(math.inf) + distance.append(None) for i in range(asd): seen.append(0) + #print("**** debug: " + str(distance), file=sys.stderr) + #print("**** debug: " + str(seen), file=sys.stderr) + dijkstra(route_to_calc[x], route_to_calc[x+1]) distance.clear() seen.clear() - - #print("**** debug ***", file=sys.stderr) - #print( route , file=sys.stderr) - #print("**** \debug ***", file=sys.stderr) + def calc_route_length(a, b):