heh
| -rw-r--r-- | src/inp.txt | 2425 | ||||
| -rw-r--r-- | src/main.rs | 182 | ||||
| -rw-r--r-- | src/util.rs | 2 |
3 files changed, 2450 insertions, 159 deletions
diff --git a/src/inp.txt b/src/inp.txt index 5ed32e5..ee8350a 100644 --- a/src/inp.txt +++ b/src/inp.txt @@ -1,5 +1,2420 @@ -140A -143A -349A -582A -964A +6484081 +5518665 +2322188 +13185644 +11468151 +1388284 +9636611 +3226171 +4010520 +8704480 +8603118 +5393150 +11154621 +9110158 +812162 +634804 +4383310 +5434726 +3752432 +9818491 +4361825 +9025210 +3871007 +10667352 +11122865 +14451457 +15751654 +10320206 +10046084 +12577654 +850564 +10599745 +1032478 +1574517 +3132722 +7005554 +2919364 +9825687 +4766896 +11811510 +8473498 +2522971 +3151141 +4511254 +1409422 +6355072 +7271377 +4798227 +11661738 +7863190 +16405311 +2952065 +2292618 +12148074 +5078742 +7193248 +3290183 +5919755 +9837278 +12058888 +7307001 +6737369 +6062325 +169199 +7470332 +7745517 +15747152 +10793045 +8369756 +2461828 +13334496 +11785677 +5014608 +16569510 +8870587 +7850718 +14959435 +11575634 +341997 +3808582 +378657 +3449264 +5536239 +7423175 +4364753 +8758928 +5114592 +4878041 +7130098 +11147610 +1700987 +14461437 +1678372 +2637595 +4819360 +11463002 +9470187 +13502683 +13145643 +9339881 +3288352 +5011100 +13767816 +11209365 +9630342 +5424038 +4504131 +15405927 +9559902 +13379213 +15862165 +8174396 +11666081 +9467754 +8155277 +8966250 +15222332 +2405421 +8979251 +10411311 +3645173 +5332901 +8744876 +11238922 +1064373 +2356494 +7177688 +11455393 +16629166 +3412283 +778935 +8466252 +12172658 +11406706 +14782001 +8528436 +10362399 +10106875 +2384775 +16471659 +13138647 +9098513 +5270815 +1783178 +10548040 +2421119 +8496846 +9364986 +10730879 +12302479 +7227964 +10284389 +4207932 +10580561 +9142872 +15837342 +16406773 +8070955 +3375394 +5514702 +351752 +16700356 +199050 +3555762 +14073362 +9463292 +1694007 +1139307 +3853877 +13159020 +7503752 +2475681 +5408203 +12458815 +9392943 +226418 +11205762 +12359325 +14537227 +15437379 +8435418 +15666689 +11531029 +2406749 +2878452 +7586273 +11481943 +8368390 +1070876 +1535940 +11503859 +15781343 +10824401 +3747286 +4144478 +16040495 +13605112 +16748357 +13370883 +521762 +15324335 +563796 +16698232 +8226816 +337070 +15273250 +15492985 +9572847 +4634911 +1645135 +10251198 +255511 +8035573 +4297847 +8629188 +5159081 +16179240 +8384609 +2223219 +14994107 +11898290 +14922539 +12362345 +14094032 +666907 +3865955 +11279755 +6405511 +2781999 +1816339 +8565320 +12323830 +10409956 +5786891 +16343478 +6794005 +4880305 +11366049 +5303670 +10436035 +13294708 +2579948 +8330748 +11384603 +9954489 +13915447 +7468408 +2267666 +2250591 +15500243 +12352096 +11811757 +988391 +1707234 +12865034 +894893 +12783173 +3486944 +15743364 +4958711 +5108407 +15405207 +12699711 +6367938 +6822450 +11088727 +3518665 +15908422 +12107804 +7816100 +2599718 +8951685 +14733687 +6182785 +11935219 +1664664 +3801648 +1404038 +4729539 +14930727 +632373 +8994457 +11909817 +11131020 +12254194 +15319752 +13277567 +5390488 +8304160 +15750443 +9765456 +2597122 +10494554 +7242008 +4099042 +1424427 +11288475 +14062802 +5677151 +8058148 +3761068 +15197767 +12116426 +13172390 +8853463 +9952954 +10318949 +6765119 +1637213 +11090263 +10245079 +9889225 +1611003 +3022306 +6944765 +5543708 +8706924 +4734526 +3129166 +15291863 +8791810 +6966653 +7678475 +9400124 +9073548 +2626204 +14087721 +6737200 +6492514 +1384795 +7267399 +15459763 +3853805 +8495873 +7951518 +9787525 +4087579 +16539604 +16659493 +11989754 +7837978 +5821170 +7456962 +1334199 +2900557 +13762072 +14283656 +11155063 +4638125 +1051482 +10769561 +10918114 +11704298 +11190609 +16413020 +6388248 +15720005 +14560409 +16473671 +11732145 +12992422 +4556927 +8027501 +5430202 +8531864 +187089 +13065624 +16075893 +14049214 +8287365 +6594192 +16039351 +472567 +3720355 +7053736 +5404694 +12288947 +13624649 +5676437 +1899873 +11638053 +4251153 +15140058 +12109676 +3722391 +8434772 +10740473 +15170483 +10362592 +16028319 +14250211 +15585280 +1384704 +12924649 +4876501 +573963 +269293 +764779 +11866147 +15660492 +6386251 +5858027 +15480334 +424500 +15739663 +12914536 +2356483 +5414661 +4572221 +13235089 +12745523 +9604751 +6527163 +11246947 +11066266 +13105265 +13675429 +7642188 +4816153 +10818718 +2167284 +14035202 +15562070 +5096808 +12611611 +1980871 +5602458 +2662865 +4785169 +8199524 +3828185 +2788335 +11920504 +2851443 +3194505 +12605387 +10869482 +5599639 +1237979 +2716448 +7561499 +13171087 +1555014 +15258357 +12754472 +10450052 +3349557 +13459266 +13636267 +9820427 +11946232 +2569134 +9514543 +688007 +7135463 +5717179 +11994965 +2050108 +16085735 +11515870 +15896680 +1366110 +6721859 +10289245 +2886721 +1148617 +10824685 +4966461 +13195863 +6354065 +9729028 +11708692 +9208893 +242886 +7861120 +6027795 +3955283 +1108493 +4564879 +3507342 +9431124 +9474644 +778320 +7689156 +14031927 +6038036 +16726023 +14294498 +1350231 +15921866 +9380597 +14032882 +13031410 +12344627 +1122960 +13013691 +14686472 +5484742 +1670816 +3917952 +14399304 +3391593 +8927324 +7311652 +10452205 +13283857 +8690270 +6590528 +4206509 +12451109 +11595730 +12580211 +12610684 +9370571 +6054101 +10063773 +13528194 +11317076 +6569357 +4973921 +14642611 +10156223 +1501190 +1644044 +13137319 +2934305 +7637591 +14703328 +3449517 +2221397 +10784259 +1539976 +1105325 +7353744 +16762624 +16340668 +15701611 +3790347 +4660007 +9874163 +10441355 +14436524 +2521647 +11888774 +2082384 +7012066 +2739634 +11701146 +15690545 +13874540 +5664752 +16572137 +5508222 +5030814 +9188961 +7851442 +15498196 +3149048 +5533261 +10340579 +13694635 +13871717 +12108010 +10892056 +13638226 +16272518 +9895314 +11531765 +2583690 +15764349 +5088994 +15280918 +11684744 +11414636 +12119696 +13326560 +249953 +11094719 +1302273 +2373007 +14160369 +2446495 +6476934 +13473252 +1178607 +5114000 +14507598 +7724865 +14239093 +3987267 +730116 +15407907 +15213366 +4655571 +10925080 +10326662 +8207290 +11549568 +13701996 +16049962 +12435020 +10590151 +7449942 +16258378 +13555674 +10746943 +11318622 +6297388 +5645003 +13027889 +6242127 +5528204 +5248978 +894976 +594112 +11107325 +15101178 +11833290 +11173138 +3951412 +3614098 +12306551 +1783209 +3918424 +16760916 +11622999 +3722941 +1529746 +13586681 +9921048 +2456034 +10649724 +3653245 +11113808 +12780807 +12124218 +9775025 +7877949 +15082295 +7229616 +6773575 +5078930 +12662544 +9048749 +3677990 +5633050 +11850082 +8242607 +9563115 +9839103 +7773166 +8131446 +1045659 +9787932 +12055740 +13233049 +15431420 +10284653 +13550834 +6503718 +7997078 +13269750 +887417 +1379682 +8905294 +7279600 +2146606 +2529505 +8878740 +12826860 +10891948 +13700185 +2270030 +3524285 +15910431 +5571299 +15728987 +8166303 +2064323 +752849 +16518656 +2071493 +12844307 +8874665 +13007812 +7420413 +13114060 +7833711 +6440495 +5810501 +9439284 +11815979 +7250270 +14422912 +12583721 +6462517 +5254646 +14507867 +15644088 +6175964 +7936443 +9899620 +15780861 +4660684 +2389043 +1899762 +9317177 +881856 +11417816 +11196945 +7292169 +1952033 +8789260 +1976074 +10131113 +1603955 +2014818 +4075087 +14252089 +9759963 +11699734 +8550829 +1189344 +1605202 +6264648 +674176 +16601235 +3965372 +4915014 +10152847 +9349442 +12233391 +4829294 +8759683 +3906260 +11734635 +3512635 +12488390 +11655546 +15352902 +3893467 +13321330 +13523809 +11235024 +12697866 +7838329 +15580097 +5159373 +12853573 +7307234 +10006760 +4647782 +2337054 +2079482 +1577902 +4437726 +15320655 +13291224 +7317058 +15045301 +8738381 +6055743 +14562579 +5949464 +7471709 +12072981 +12612098 +3570791 +10579905 +4615181 +16112600 +3515311 +11338576 +3936234 +12954945 +5931790 +4368321 +851686 +7992150 +6940748 +290836 +8186440 +3802883 +14554920 +6470418 +11959292 +14117424 +12521845 +16271690 +4993831 +2614499 +14816101 +13868016 +15823934 +8409881 +10190423 +15007742 +7927040 +2506043 +7729094 +15885641 +14410186 +2270878 +16364859 +9571506 +9969275 +16106141 +14636696 +14166618 +8534719 +7994699 +11373421 +15777963 +1708550 +6173624 +12973019 +11050554 +568290 +4754763 +14649060 +13494988 +3109751 +12078723 +12082467 +648836 +8390127 +3512808 +1420410 +12597481 +11993456 +12550355 +12330358 +9155493 +1563156 +2774762 +15465213 +196068 +3002789 +11467818 +13997633 +14807296 +8774516 +14026080 +266468 +12399735 +11174076 +15879662 +6626275 +15664758 +12463401 +15647414 +1370101 +4797953 +4116460 +6817995 +6633954 +6995055 +5989803 +15476399 +8073131 +4762678 +1295365 +2582389 +5361747 +10574600 +10715658 +16605226 +13016228 +2868239 +8037143 +14163093 +6857087 +955513 +15742180 +3408949 +13140194 +8820687 +8333139 +8896263 +9395287 +13578838 +12635785 +13186674 +667186 +13772165 +7399274 +15756604 +15529406 +15553728 +1957169 +16397628 +131450 +12383956 +14241277 +7495143 +10145845 +1923626 +13260216 +10332051 +13534027 +13295228 +6062937 +12197824 +7083768 +2309574 +6434506 +6835778 +6276970 +4644692 +3958313 +10175896 +16566036 +8217150 +8595936 +11267401 +2630327 +8810564 +13441353 +7153515 +10233483 +11556303 +6293265 +15885810 +11037739 +8380395 +9094753 +12139710 +8773376 +13837407 +3838473 +15666594 +15158081 +1874544 +4980346 +1728514 +6002446 +5194682 +12441638 +14897367 +14848915 +5079881 +891709 +6817320 +4373189 +6819195 +15165727 +12035403 +14506746 +16741462 +11414777 +13115707 +5974363 +3281362 +10929433 +11579848 +873726 +148274 +5233454 +4718625 +11514791 +11294132 +10292397 +15361431 +12323799 +11234572 +4204217 +3148124 +11975786 +7390873 +2402478 +7961872 +10538203 +13416690 +996953 +10594795 +13099244 +16242017 +3469618 +5481540 +4754332 +6602713 +14434228 +6044956 +12015119 +13451650 +16178368 +592964 +1809538 +743759 +16136328 +593279 +14195522 +1811725 +8745483 +8641263 +8123694 +11430691 +11093300 +16374458 +4999814 +14764467 +12916789 +1204443 +12295794 +16288239 +7754560 +11832188 +5775862 +15939177 +8909555 +2913346 +10760495 +1325007 +981030 +1433159 +977121 +16596144 +10172816 +10269559 +4822234 +13655604 +15467999 +11536208 +1673234 +8459325 +1829159 +14796000 +11387902 +3858203 +1003664 +6894895 +14389824 +4672259 +3560473 +13233644 +9115778 +3328407 +16177628 +16052636 +10194751 +16316234 +6939152 +12750341 +2395909 +9493750 +3866650 +12467958 +5415409 +13807843 +9491863 +6761978 +12160523 +6198645 +11168029 +2043597 +5740178 +15883815 +2039189 +6612954 +10160998 +15989958 +12396972 +14121262 +11603037 +14276806 +10295984 +16576191 +2779009 +12904535 +15017060 +5265389 +3228450 +11032088 +14406137 +258438 +9110525 +1912491 +5489706 +14587045 +400080 +3528183 +2836431 +6026984 +14186573 +13020332 +2822100 +7492526 +9373825 +14197463 +11775837 +15017211 +13128888 +11907903 +2465349 +7516617 +9382427 +12526875 +6339763 +11512208 +12427640 +12494089 +9579407 +15320493 +11876102 +14676829 +8632525 +6007917 +2864461 +7875520 +13924707 +11534921 +13226508 +6496436 +5830794 +12703709 +15440974 +11828175 +13745768 +6312423 +5289455 +15880604 +8390894 +13735826 +857410 +9936069 +4272549 +14847466 +9329596 +13571995 +11486378 +15184214 +16001361 +4889687 +6895801 +4731506 +6557541 +11041591 +5478468 +15224460 +11308880 +6549849 +11888890 +11491475 +2485436 +3371885 +2227168 +11596014 +1730950 +12460942 +6350140 +3939681 +717896 +4084011 +9149190 +8462487 +11565597 +16190618 +11119444 +14854035 +5983505 +7134458 +8766552 +7595206 +3319842 +2340366 +4857365 +6027497 +11132384 +3411061 +5082268 +2509921 +3447888 +4650955 +3310064 +4826147 +14200334 +9751709 +12882458 +3436202 +6380159 +1411502 +5389277 +3955641 +10023775 +3761585 +8027808 +5922857 +3541496 +15416029 +12610491 +2169110 +5789701 +13792415 +9685031 +9280325 +15965308 +10121348 +10286295 +1988494 +5167426 +8740270 +13353351 +10440586 +5550418 +9104756 +16003268 +1739212 +7447759 +13923200 +1199647 +10022415 +978722 +16462697 +4612655 +7900154 +10195070 +972026 +9075933 +4332808 +1907938 +10784355 +7636695 +16408660 +2698540 +7158851 +10023060 +15990766 +15826867 +11209196 +11034974 +1179497 +9636754 +4038757 +14372116 +4027721 +6189285 +2895771 +2194716 +4944075 +6983419 +2073264 +6218206 +7114384 +1817858 +10190275 +14714776 +2145370 +696172 +1656963 +14843123 +13572628 +5384730 +4457625 +2598113 +10588149 +1946188 +10910090 +10989979 +15112837 +6783277 +10323892 +10313058 +4829389 +14808607 +16392732 +1896602 +8747770 +8299497 +15655240 +11431280 +8944390 +8581960 +12693699 +12292283 +9810437 +824745 +10040302 +11212846 +6737397 +9546111 +5172636 +11491354 +13523397 +10939353 +10467164 +3188990 +16633515 +464621 +12771745 +14170149 +8914554 +1693612 +12491749 +15042592 +6546961 +8334215 +15379319 +11714475 +7788690 +3532897 +14327844 +11645113 +936774 +11628718 +12105444 +13125627 +2452147 +12305125 +689055 +6975456 +11421323 +4006564 +775044 +8852340 +8703916 +14833946 +8356054 +8068583 +402534 +15474399 +3415770 +15234415 +3004385 +9480347 +11036795 +3210375 +16550987 +11984842 +15703382 +13348085 +6342938 +10401338 +5101393 +15896093 +4954484 +4178939 +15578482 +12148017 +4364093 +10770706 +3100527 +8033188 +6926395 +13833325 +12027778 +10584060 +4423657 +15037808 +12369241 +12740758 +13800854 +3121866 +15422534 +4739195 +1617520 +689498 +9969856 +11709791 +2214415 +2190927 +15518702 +2358586 +4931883 +1423896 +5353544 +7084695 +11113684 +8684375 +12924570 +848553 +13413545 +1220456 +9035570 +10809508 +3311420 +9322269 +14348035 +5980272 +12651693 +6682310 +14822205 +15319284 +3116132 +8406716 +4169557 +982393 +1406585 +9666187 +5867692 +3426171 +2937898 +5690869 +11802601 +1941553 +6607723 +10585637 +10461624 +1881254 +14685250 +13602771 +6516466 +6619603 +2174551 +13798978 +12381785 +15802726 +10401182 +8564914 +352179 +8402239 +12693938 +12173621 +11724987 +15855746 +14323694 +5400240 +11769708 +6716214 +8706025 +15453531 +4149823 +4626915 +11522142 +12397342 +1230210 +15429499 +16417543 +13277402 +13737051 +12502523 +6853742 +15613177 +3595288 +2034610 +8311806 +14508916 +12458058 +16103677 +5283077 +6083058 +1570208 +15486580 +8170936 +4470985 +2461642 +907017 +4671876 +2046235 +6474631 +14562948 +5362498 +9245392 +11491547 +4948990 +13223452 +13434809 +8163740 +4608905 +8160305 +3193291 +4576729 +14535456 +8717336 +14298704 +4481357 +159555 +11230632 +6638731 +14262973 +2364466 +11710048 +14150010 +8267598 +15975331 +5511681 +14838098 +5140470 +4896065 +1300452 +1714046 +5127634 +2872233 +4623508 +7023895 +12696228 +11168194 +7707971 +6209871 +14910692 +2051722 +16575132 +8170612 +3092894 +12362023 +7036492 +912112 +11657742 +11298288 +2823599 +14952226 +697880 +9187502 +16748459 +8721604 +12097496 +1552849 +5517263 +590893 +12707397 +6897026 +15954039 +12934376 +4250949 +13573578 +5653633 +15704778 +6934490 +13381082 +5581532 +8129810 +2327786 +16215385 +13714933 +3356935 +6375357 +10754390 +16454300 +16131847 +1465013 +2663924 +10944696 +10901291 +1610698 +11504174 +15978409 +4699960 +13444873 +8658792 +16317404 +13841424 +14668555 +4090475 +7097993 +15764107 +11074881 +4070488 +4816688 +11052100 +11796532 +5091801 +7818193 +4061667 +9216829 +3972708 +10628196 +13011763 +4524483 +840404 +10173279 +2147179 +16545553 +2468559 +703406 +3584825 +1645225 +12189092 +12461982 +2514743 +1785724 +15492633 +12812250 +13715161 +9514442 +3873682 +14282890 +9626180 +16370476 +14175865 +5462352 +2269926 +10188349 +15588448 +9702833 +2316388 +2435719 +2125471 +9810691 +9758452 +8193437 +2054736 +10396140 +6718242 +4499205 +7185324 +11470784 +5146319 +11495757 +12956268 +11094800 +14098724 +615091 +2163409 +737771 +12856660 +16168716 +9533488 +6988615 +1132325 +639498 +7212153 +1248017 +8486503 +14856368 +13116751 +4318565 +7727360 +15493548 +10071144 +16503901 +2470750 +12732011 +1937333 +13930710 +15103728 +10334496 +16582606 +5243998 +12102316 +11259499 +10029427 +16663931 +10119286 +2159414 +15846303 +10570274 +577808 +9553984 +7804872 +5593894 +6796293 +15277086 +9506607 +7903519 +5392415 +9171412 +3450861 +10548207 +3377144 +14630112 +14807162 +640234 +4840297 +7132002 +1855951 +10974245 +794338 +15254334 +5099776 +661297 +10924819 +7255860 +6263398 +10642966 +13188797 +16223138 +12946938 +540705 +4997527 +16576731 +16702308 +12376075 +14107267 +7282033 +1946527 +171090 +5541081 +15907606 +743718 +15880049 +16733384 +134358 +865672 +9471165 +2804902 +10514425 +5523352 +3621339 +12714271 +4348924 +1606170 +16200732 +10881964 +14747356 +14924169 +12454068 +11057671 +8914167 +13617622 +4959989 +169440 +1314188 +7547726 +13691192 +9583304 +8773499 +7717677 +9998717 +13373746 +1773415 +2724979 +6205308 +1325974 +14967213 +12747772 +9116796 +7284261 +10215883 +12440284 +10517277 +13799689 +5435098 +11708204 +16522237 +14412044 +12274561 +1118634 +7518534 +13080957 +9132192 +3328121 +10047512 +15922271 +1443408 +11032961 +14068982 +12653196 +13555803 +8135637 +2375075 +8147953 +3036008 +1569673 +10517542 +7804962 +9443407 +2414954 +6797843 +1114228 +4080836 +6206410 +13467099 +6891100 +5694842 +9894572 +2892631 +5356057 +816966 +3316538 +6912676 +3964616 +10343542 +4003975 +11207174 +11309233 +8929949 +3509538 +3389088 +14305563 +13927775 +3771920 +5362071 +9787174 +482748 +15732519 +6680962 +10104582 +13124631 +4011729 +6477823 +9478061 +2727928 +12793508 +3280574 +13109814 +8422386 +11838216 +4739971 +11054467 +2220169 +9830819 +6081864 +9863983 +16197394 +3158011 +16241398 +14026914 +6881166 +13067549 +10279954 +472842 +3384192 +12168642 +13191752 +12324664 +15457608 +6247886 +14134710 +9904573 +14412119 +9662345 +9265825 +10551365 +8678840 +3406925 +7385974 +12821002 +552697 +9225940 +8692443 +15370814 +11087940 +8462510 +3153157 +16085929 +10877366 +1244585 +1661601 +8513548 +10034326 +566621 +2744370 +8614866 +498381 +15722288 +11843599 +6227522 +7507812 +10200192 +2662661 +7138239 +15591999 +9834944 +6823171 +5179889 +6810435 +14577290 +13506628 +1209406 +16501332 +11569356 +1484552 +5497315 +14056246 +10503237 +10865681 +12537075 +9367615 +13822134 +3533335 +6179504 +15576618 +4469262 +11752320 +1259884 +13307866 +16271878 +16391162 +1826158 +9042948 +7400830 +1242076 +5938586 +5495250 +9321715 +13589415 +6512760 +2469486 +3539515 +3943304 +14789317 +13499711 +15774150 +12148047 +7381256 +549137 +11859501 +6403093 +12187057 +12848910 +3554838 +1610112 +6462486 +5789291 +8476884 +3386013 +14271983 +2464553 +4960841 +11918103 +12233813 +5945315 +11332864 +15786722 +14407182 +7910601 +10511977 +12981588 +7852696 +15696210 +13191064 +8908616 +4002751 +16194780 +11667638 +11995356 +1572250 +6631848 +16144832 +10558773 +931466 +10716914 +16714757 +4586484 +6845799 +10838998 +6383626 +7244506 +5552935 +1287832 +5511001 +6080450 +4079188 +5254323 +9825266 +13799675 +13236524 +14319750 +5573556 +8997345 +3630812 +6587384 +5752940 +4128962 +9674769 +6159519 +15161510 +13641484 +10797889 +530452 +11539885 +4926237 +10285120 +4253465 +16477064 +11870523 +3578183 +6993386 +6132730 +10046658 +11762745 +1536202 +16124138 +1884398 +7482862 +15263556 +13471922 +905053 +1385841 +9031676 +2511659 +8437503 +5244537 +6460421 +6009939 +10606068 +2449410 +14083257 +4203702 +11172285 +1375666 +1002472 +9620400 +11714573 +4952017 +10335479 +3946469 +10014115 +8064438 +8153051 +14690847 +5616811 +5474616 +12727959 +8149507 +15525748 +10739239 +12938164 +3718603 +14474136 +10610401 +11808412 +10197601 +8655624 +10143277 +13695588 +13130482 +5353770 +9436632 +6811266 +15534608 +2828182 +6291732 +4081754 +4660816 +11589096 +9748621 +3566132 +2438176 +12124102 +4019173 +9453882 +12063324 +9822522 +10410179 +3703414 +6486518 +14444895 +14242268 +6852507 +5340846 +9376673 +13936674 +13136192 +7336618 +15803851 +15715609 +12148469 +5665850 +1002122 +3716724 +10356457 +11063279 +4649558 +12177494 +9505131 +11551899 +7490873 +1465401 +4905113 +13213304 +15408217 +3522073 +7662750 +6004282 +15495158 +339875 +1090025 +10353504 +320308 +2285862 +4217394 +8651381 +10395617 +2744732 +10218779 +3574671 +2021205 +3070363 +3932727 +14759579 +2961309 +14471148 +11114206 +4924817 +13468447 +1368461 +5328667 +7547873 +9712200 +6789413 +8844283 +930272 +1701877 +10544004 +6812761 +9283107 +12179409 +6125156 +3424487 +12437795 +12277571 +7523502 +6843015 +16098456 +6951741 +7734929 +2200736 +1313615 +9641151 +15557677 +14957813 +7551817 +2283744 +16617003 +9818559 +10096185 +10800320 +7553104 +2287246 +2566003 +489501 +15103565 +7143975 +365953 +5945063 +143903 +754972 +14415008 +12450228 +6425844 +2239309 +8227169 +8698609 +10071824 +11068320 +5178284 +14614822 +5517370 +2882160 +16373080 +11234044 +7430209 +14960112 +5255281 +12547403 +7775624 +3516863 +12647209 +15959046 +10227221 +9697594 +13315673 +2959764 +14116207 +929998 +3160623 +11240184 +4890249 +7534244 +7470995 +9889547 +9903164 +1913925 +3845754 +2169346 +12504114 +3333808 +15738398 +12093859 +2131685 +12663367 +16006853 +16545695 +3644187 +10042768 +11426168 +9268194 +14560101 +3762780 +15242143 +13610498 +9199754 +11166230 +16164629 +13111395 +6828845 +9474417 +15771113 +11736892 +553443 +14097002 +12644211 +10214993 +4318655 +13321143 +14071305 +6442984 +16072354 +9659195 +3779826 +11721567 +2189583 +7981030 +15642840 +1855407 +13154477 +16416650 +8445239 +13210428 +3212492 +16120000 +8399566 +13780057 +4488693 +15009985 +3588442 +2806313 +1518887 +752461 +13970773 +1974748 +15545770 +6115404 +9434251 +10714527 +13898034 +12945838 +8918490 +3495696 +6357748 +7595336 +2757754 +5417904 +5132414 +6497281 +9746810 +2999403 +3657334 +6896270 +13886008 +9641747 +2544391 +5945909 +11002846 +2944911 +6453132 +4604596 +2710987 +2196345 +16352788 +1790792 +1973052 +883684 +6339987 +8020282 +13756978 +2894642 +6944798 +8968139 +218863 +5582375 +6611226 +8604041 +1442584 +10855593 +3634532 +16611114 +11471280 +14167582 +12688475 +4935157 +5339376 +11486157 +14704193 +8593549 +5276646 +10934098 +1253846 +13384294 +14320564 +3518697 +7075810 +14268890 +1394178 +2242317 +6573929 +8396767 +15026184 +6665212 +11595636 +6234286 +10182259 +4215662 +7353282 +2912138 +12756467 +9750818 +9121650 +12784317 +9658912 +427235 +3892099 +1600876 +5002233 +8359946 +5078558 +9493647 +7598568 +2328776 +13134593 +16538752 +13853898 +10870294 +9085905 +10034943 +11670312 +9732490 +8841449 +12111700 +10576180 +11214895 +15241011 +11607393 +13493437 +14145028 +13602227 +8208858 +8985529 +3002054 +12850428 +11589580 +1338756 +15650679 +9460533 +3443359 +16076374 +9567279 +12943448 +1947236 +484557 +193242 +5508929 +13945606 +6024929 +11238075 +2830477 +14859290 +190661 +15097812 +3646363 +11096004 +12579232 +14007750 +5502969 +4790468 +11082313 +4259117 +1654055 +14109754 +14675288 +7892511 +7395343 +7111691 +8161582 +1370114 +1098675 +3179748 +2408357 +6270962 +8326493 +14552066 +409443 +1013885 +12036911 +13031039 +8252337 +8277428 +10233420 +5764074 +13700353 +10959989 +734897 +15274268 +2488624 +16408853 +11277993 +16113918 +10844851 +6718886 +10136874 +13817799 +15963324 +5679263 +10281361 +7070908 +1866620 +7313124 +13866775 +14687980 +2924129 +10976745 +2788072 +16709014 +3447379 +5445893 +6630430 +3112233 +4501127 +10638861 +14321898 +13113456 +3142546 +13323734 +7837410 +2149305 +7791877 +908116 +2352638 +3333856 +6868404 +13137130 +7447793 +14781735 +10949000 +14353584 +14854746 +11530140 +13441116 +9634690 +15194156 diff --git a/src/main.rs b/src/main.rs index f016cab..5c90853 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,165 +34,41 @@ )] extern crate test; pub mod util; -use atools::CollectArray; -use iter::once; -use util::memoize; pub use util::prelude::*; - -#[rustfmt::skip] -fn numpad(x: u8) -> (usize, usize) { - match x { - b'7' => (0, 0), b'8' => (1, 0), b'9' => (2, 0), - b'4' => (0, 1), b'5' => (1, 1), b'6' => (2, 1), - b'1' => (0, 2), b'2' => (1, 2), b'3' => (2, 2), - b'0' => (1, 3), b'A' => (2, 3), - _ => unreachable!(), - } -} -#[rustfmt::skip] -fn dpad(x: u8) -> (usize, usize) { - match x { - b'^' => (1, 0), b'A' => (2, 0), - b'<' => (0, 1), b'v' => (1, 1), b'>' => (2, 1), - _ => unreachable!(), - } -} -fn pathfind<const N: usize, const M: usize>( - input: impl IntoIterator<Item = (u8, (usize, usize))>, - grid: [[u8; N]; M], -) -> Vec<Vec<u8>> { - let mut ways = HashSet::<Vec<u8>>::default(); - for ((code, start), first) in input - .into_iter() - .zip(std::iter::once(true).chain(std::iter::repeat(false))) - { - let current = pathfinding::directed::astar::astar_bag( - &(start, code, b'.'), - |&(p, at, _)| { - [ - (Dir::N + p, b'^'), - (Dir::E + p, b'>'), - (Dir::S + p, b'v'), - (Dir::W + p, b'<'), - ] - .into_iter() - .filter(|&((x, y), _)| matches!(grid.get(y).map(|y| y.get(x)), Some(Some(_)))) - .filter(|&((x, y), _)| grid[y][x] != 0) - .map(move |(p, dir)| ((p, at, dir), 1)) - }, - |_| 0, - |&((x, y), at, _)| grid.get(y).map(|y| y.get(x)) == Some(Some(&at)), - ) - .ψ() - .0 - .into_iter() - .map(|x| { - x.into_iter() - .skip(1) - .map(|x| x.2) - .chain(once(b'A')) - .collect_vec() - }) - .collect_vec(); - - if first { - ways.extend(current); - } else { - ways = ways - .into_iter() - .flat_map(|x| { - current.iter().map(move |way| { - let mut x = x.clone(); - x.extend(way); - x - }) - }) - .collect(); - } - } - - ways.into_iter().collect_vec() -} - -fn num(code: [u8; 4]) -> Vec<Vec<u8>> { - #[rustfmt::skip] - let grid = [ - [b'7',b'8',b'9'], - [b'4',b'5',b'6'], - [b'1',b'2',b'3'], - [0 , b'0',b'A'], - ]; - let starts = once(numpad(b'A')).chain(code.iter().copied().map(numpad)); - pathfind(code.iter().copied().zip(starts), grid) -} -fn pad(code: Vec<u8>) -> Vec<Vec<u8>> { - #[rustfmt::skip] - let grid = [ - [0, b'^',b'A'], - [b'<',b'v',b'>'], - ]; - let starts = once(dpad(b'A')).chain(code.iter().copied().map(dpad)); - pathfind(code.iter().copied().zip(starts), grid) -} - -const MAXDEPTH: u8 = 2; -fn solve(thing: Vec<u8>, deep: u8) -> usize { - if deep == MAXDEPTH { - return thing.len(); - } - memoize!(|(thing, deep) in (Vec<u8>, u8)| -> usize { - thing[..thing.len() - 1] - .split(|x| *x == b'A') - .into_iter() - .map(|x| { - let mut x = x.to_vec(); - x.push(b'A'); - pad(x.to_vec()) - .into_iter() - .map(|x| solve(x, deep + 1)) - .min() - .unwrap() - }) - .sum() - }; (thing, deep)) +#[no_mangle] +fn changes(mut x: u64) -> [(u8, i8); 2001] { + let mut secret = x; + x %= 10; + std::array::from_fn(|_| { + secret ^= (secret * 64) % 16777216; + secret ^= (secret / 32) % 16777216; + secret ^= (secret * 2048) % 16777216; + let n = secret % 10; + let v = (x as u8, (n as i64 - x as i64) as i8); + x = n; + v + }) } -static P2: [u64; 3750202] = { - let mut l = [0; 3750202]; - include!("../lut"); - l -}; -static P1: [u64; 3750202] = { - let mut l = [0; 3750202]; - include!("../lut2"); - l -}; #[no_mangle] pub fn run(x: &str) -> impl Display { let i = x.as_bytes(); - let codes: &[[u8; 5]; 5] = unsafe { i.as_chunks_unchecked::<5>().try_into().ψ() }; - /* - for code in 1..1000 { - let code_ = format!("{code:03}A"); - let code__ = code_.as_bytes(); - let length = num(code_.as_bytes()[..4].try_into().unwrap()) - .into_iter() - .map(|x| solve(x, 0)) - .min() - .unwrap() as u64; - print!( - "l[{}]={};", - u32::from_le_bytes(code__.try_into().unwrap()) & 16777215, - length * code as u64 - ); - } - return 0; - */ - - codes - .into_iter() - .map(|x| C! { P1[u32::from_le_bytes(x[..4].try_into().ψ()) as usize & 0xffffff] }) - .sum::<u64>() + let mut map = HashMap::<[i8; 4], u16>::with_capacity_and_hasher( + 50000, + rustc_hash::FxBuildHasher::default(), + ); + let mut seen = + HashSet::<[i8; 4]>::with_capacity_and_hasher(2000, rustc_hash::FxBuildHasher::default()); + i.行().map(reading::all::<u64>).map(changes).for_each(|x| { + for &[elem @ .., (p, _)] in x.array_windows::<5>() { + let elem = elem.map(|x| x.1); + if seen.insert(elem) { + *map.entry(elem).or_default() += p as u16; + } + } + seen.clear(); + }); + map.into_iter().r().max().ψ() } fn main() { diff --git a/src/util.rs b/src/util.rs index 4f9f819..6d4b5d9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,4 @@ -#![allow(non_snake_case, unused_macros)] +#![allow(non_snake_case, unused_macros, unused_unsafe)] use rustc_hash::FxHashMap as HashMap; use rustc_hash::FxHashSet as HashSet; |