Task: | Keke's delivery service |
Sender: | aalto2024k_005 |
Submission time: | 2024-11-13 17:43:37 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.01 s | details |
#34 | ACCEPTED | 0.01 s | details |
#35 | ACCEPTED | 0.01 s | details |
#36 | ACCEPTED | 0.01 s | details |
#37 | ACCEPTED | 0.01 s | details |
#38 | ACCEPTED | 0.01 s | details |
#39 | ACCEPTED | 0.01 s | details |
#40 | ACCEPTED | 0.02 s | details |
#41 | ACCEPTED | 0.02 s | details |
#42 | ACCEPTED | 0.01 s | details |
#43 | ACCEPTED | 0.05 s | details |
#44 | ACCEPTED | 0.05 s | details |
#45 | ACCEPTED | 0.05 s | details |
#46 | ACCEPTED | 0.05 s | details |
#47 | ACCEPTED | 0.05 s | details |
#48 | ACCEPTED | 0.20 s | details |
#49 | ACCEPTED | 0.20 s | details |
#50 | ACCEPTED | 0.20 s | details |
#51 | ACCEPTED | 0.20 s | details |
#52 | ACCEPTED | 0.20 s | details |
#53 | ACCEPTED | 0.86 s | details |
#54 | ACCEPTED | 0.86 s | details |
#55 | ACCEPTED | 0.86 s | details |
#56 | ACCEPTED | 0.86 s | details |
#57 | ACCEPTED | 0.86 s | details |
#58 | ACCEPTED | 0.87 s | details |
#59 | ACCEPTED | 0.86 s | details |
#60 | ACCEPTED | 0.87 s | details |
#61 | ACCEPTED | 0.86 s | details |
#62 | ACCEPTED | 0.86 s | details |
Compiler report
input/code.cpp: In function 'long double Shortest(std::array<std::pair<std::complex<long double>, std::complex<long double> >, 10>&, std::complex<long double>, std::string)': input/code.cpp:37:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::array<std::pair<std::complex<long double>, std::complex<long double> >, 10>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 37 | for (int i = 0; i < points.size(); i++) | ~~^~~~~~~~~~~~~~~ input/code.cpp: In function 'void solve()': input/code.cpp:68:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::array<std::pair<std::complex<long double>, std::complex<long double> >, 10>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 68 | for (int i = 0; i < points.size(); i++) | ~~^~~~~~~~~~~~~~~ input/code.cpp:75:23: warning: narrowing conversion of 'a' from 'long long int' to 'long do...
Code
#include <iostream> #include <vector> #include <array> #include <string> #include <algorithm> #include <numeric> #include <unordered_map> #include <unordered_set> #include <queue> #include <climits> #include <cmath> #include <functional> #include <type_traits> #include <fstream> #include <bitset> #include <complex> #include <iomanip> #define int long long using namespace std; #define cross(x, y) (((x)*conj(y)).imag()) #define mag(x) (sqrt(x.imag() * x.imag() + x.real() * x.real()) #define sign(v) ((0 < (v)) - ((v) < 0)) unordered_map<string, long double> mp; int A = 917563753; int B = 1946186274; long double Shortest(array<pair<complex<long double>, complex<long double>>, 10>& points, complex<long double> from, string hash) { if (mp.find(hash) != mp.end()) return mp[hash]; long double dist = LLONG_MAX; for (int i = 0; i < points.size(); i++) { if (points[i].first.real() == LLONG_MAX) continue; auto p1 = points[i].first; auto p2 = points[i].second; points[i] = {p2, {LLONG_MAX, LLONG_MAX}}; string newHash = hash; newHash[i+1]++; newHash[0] = i+'0'; dist = min(dist, Shortest(points, p1, newHash) + abs(from - p1)); points[i] = {p1, p2}; } mp[hash] = dist == LLONG_MAX ? abs(from) : dist; if (dist == LLONG_MAX) return abs(from); else return dist; } void solve() { int n; cin >> n; array<pair<complex<long double>, complex<long double>>, 10> points; for (int i = 0; i < points.size(); i++) points[i] = {{LLONG_MAX, LLONG_MAX}, {LLONG_MAX, LLONG_MAX}}; for (int i = 0; i < n; i++) { int a, b, c, d; cin >> a >> b >> c >> d; points[i] = {{a, b}, {c, d}}; } cout << Shortest(points, {0, 0}, "00000000000"); } signed main() { ios::sync_with_stdio(0); cout.precision(25); //setprecision(10); //cin.tie(0); int t = 1; //cin >> t; //ifstream f("testcase.txt"); //cin.rdbuf(f.rdbuf()); for (int i = 0; i < t; i++) solve(); }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 2 5 7 |
correct output |
---|
17.24151748197526515596 |
user output |
---|
17.24151748197526515422873 |
Test 2
Verdict: ACCEPTED
input |
---|
1 -2 10 5 9 |
correct output |
---|
27.56473698003804521928 |
user output |
---|
27.56473698003804521927673 |
Test 3
Verdict: ACCEPTED
input |
---|
2 -1 -7 -10 9 1 9 -1 0 |
correct output |
---|
46.64817201984418185146 |
user output |
---|
46.64817201984418185492509 |
Test 4
Verdict: ACCEPTED
input |
---|
2 1 -9 4 7 -4 -8 0 1 |
correct output |
---|
38.53321457061962859031 |
user output |
---|
38.5332145706196285903089 |
Test 5
Verdict: ACCEPTED
input |
---|
2 6 2 -6 8 7 8 10 -7 |
correct output |
---|
58.49347834429028263753 |
user output |
---|
58.49347834429028263406036 |
Test 6
Verdict: ACCEPTED
input |
---|
2 6 2 -6 8 7 8 10 -7 |
correct output |
---|
58.49347834429028263753 |
user output |
---|
58.49347834429028263406036 |
Test 7
Verdict: ACCEPTED
input |
---|
3 10 8 1 -7 10 7 5 2 4 2 -6 -8 |
correct output |
---|
47.94841075476520489418 |
user output |
---|
47.94841075476520489417886 |
Test 8
Verdict: ACCEPTED
input |
---|
3 -6 -9 8 7 -6 -3 9 10 0 -9 2 -2 |
correct output |
---|
53.42086935541394488933 |
user output |
---|
53.42086935541394488932698 |
Test 9
Verdict: ACCEPTED
input |
---|
3 8 9 -4 -6 7 -9 -10 -3 -8 10 2 -8 |
correct output |
---|
75.43730966940650396746 |
user output |
---|
75.43730966940650396745927 |
Test 10
Verdict: ACCEPTED
input |
---|
3 8 4 2 -1 -5 -8 -7 -7 -2 -7 -8 -5 |
correct output |
---|
41.03401888405835429979 |
user output |
---|
41.03401888405835430326252 |
Test 11
Verdict: ACCEPTED
input |
---|
3 -4 4 0 -4 6 1 6 -8 8 -8 -7 -6 |
correct output |
---|
51.02746211319720185187 |
user output |
---|
51.02746211319720185534132 |
Test 12
Verdict: ACCEPTED
input |
---|
3 -1 -1 -4 4 -6 -5 -5 -10 7 4 -8 0 |
correct output |
---|
49.16957315214831639866 |
user output |
---|
49.16957315214831639865745 |
Test 13
Verdict: ACCEPTED
input |
---|
3 5 -9 2 5 9 7 -7 8 6 -9 -3 9 |
correct output |
---|
56.01093630215238362152 |
user output |
---|
56.01093630215238362152208 |
Test 14
Verdict: ACCEPTED
input |
---|
4 -9 -6 6 -4 -1 10 5 -1 10 -4 1 -5 0 -9 -9 -2 |
correct output |
---|
69.46799309053363308958 |
user output |
---|
69.46799309053363308957829 |
Test 15
Verdict: ACCEPTED
input |
---|
4 8 -10 10 -5 8 -3 1 7 -6 -2 -10 2 -1 6 -2 -2 |
correct output |
---|
62.32599841627421704063 |
user output |
---|
62.3259984162742170371585 |
Test 16
Verdict: ACCEPTED
input |
---|
4 -10 -3 0 0 0 -10 -8 -4 -8 -10 -6 8 -2 -8 -5 -8 |
correct output |
---|
49.37474628842959419733 |
user output |
---|
49.37474628842959419386394 |
Test 17
Verdict: ACCEPTED
input |
---|
4 9 -10 3 -3 5 -10 -8 6 -9 -3 6 8 -4 5 1 4 |
correct output |
---|
70.54491148050797239000 |
user output |
---|
70.54491148050797238305831 |
Test 18
Verdict: ACCEPTED
input |
---|
4 3 2 0 9 1 3 8 5 4 -6 5 -8 5 7 -6 10 |
correct output |
---|
55.77371783018015604511 |
user output |
---|
55.77371783018015604857509 |
Test 19
Verdict: ACCEPTED
input |
---|
4 4 5 0 7 7 5 -10 4 6 -6 1 10 -4 2 -10 0 |
correct output |
---|
58.25155150420911822143 |
user output |
---|
58.25155150420911822142789 |
Test 20
Verdict: ACCEPTED
input |
---|
4 -7 3 -4 -6 -9 3 -1 -5 7 1 9 2 5 5 6 8 |
correct output |
---|
51.95472904146592808827 |
user output |
---|
51.95472904146592809174199 |
Test 21
Verdict: ACCEPTED
input |
---|
4 8 3 -7 6 0 6 9 -8 -2 8 -9 -9 9 -6 3 -2 |
correct output |
---|
71.27875557664922673284 |
user output |
---|
71.2787555766492267328438 |
Test 22
Verdict: ACCEPTED
input |
---|
4 6 -7 1 10 -8 -6 3 -9 -9 -7 -4 -9 -2 5 1 -7 |
correct output |
---|
64.30357123791869498886 |
user output |
---|
64.30357123791869499579432 |
Test 23
Verdict: ACCEPTED
input |
---|
5 3 9 -3 -6 3 -2 -7 3 10 4 -3 2 10 9 -6 4 ... |
correct output |
---|
65.29921928785613079865 |
user output |
---|
65.29921928785613079171402 |
Test 24
Verdict: ACCEPTED
input |
---|
5 -4 -10 10 -4 6 2 10 3 -6 -3 -8 -6 9 9 -9 9 ... |
correct output |
---|
82.23748773331917538004 |
user output |
---|
82.23748773331917538698121 |
Test 25
Verdict: ACCEPTED
input |
---|
5 8 -9 -3 -2 1 -4 10 5 5 5 7 -3 -8 -1 9 -5 ... |
correct output |
---|
67.56153807887115932823 |
user output |
---|
67.56153807887115932823141 |
Test 26
Verdict: ACCEPTED
input |
---|
5 -5 4 -1 4 -2 9 -5 -8 8 5 -7 2 -10 7 10 8 ... |
correct output |
---|
86.95689997133690237602 |
user output |
---|
86.95689997133690238295678 |
Test 27
Verdict: ACCEPTED
input |
---|
5 -10 -6 6 -2 -9 -2 3 -1 -10 -8 9 5 -2 -3 -5 -2 ... |
correct output |
---|
60.24622192778474186192 |
user output |
---|
60.24622192778474186192206 |
Test 28
Verdict: ACCEPTED
input |
---|
5 -1 -1 -4 4 -6 -5 -5 -10 7 4 -8 0 3 2 -5 -5 ... |
correct output |
---|
56.09845589945781874422 |
user output |
---|
56.09845589945781873728037 |
Test 29
Verdict: ACCEPTED
input |
---|
5 5 -9 2 5 9 7 -7 8 6 -9 -3 9 -7 0 -5 -2 ... |
correct output |
---|
66.46035926536274213855 |
user output |
---|
66.46035926536274213161093 |
Test 30
Verdict: ACCEPTED
input |
---|
5 9 -8 -1 1 -6 5 2 -4 3 8 4 -9 -8 3 5 3 ... |
correct output |
---|
68.92236432287188030443 |
user output |
---|
68.92236432287188030443303 |
Test 31
Verdict: ACCEPTED
input |
---|
5 -2 8 8 9 9 8 4 -2 3 9 2 1 -6 -7 -2 -8 ... |
correct output |
---|
68.57347683433427024124 |
user output |
---|
68.57347683433427024124462 |
Test 32
Verdict: ACCEPTED
input |
---|
5 1 -10 6 7 7 -3 -8 7 2 2 1 -2 -1 -6 -1 4 ... |
correct output |
---|
67.26306049003909036388 |
user output |
---|
67.2630604900390903569396 |
Test 33
Verdict: ACCEPTED
input |
---|
6 633196515 485923574 -954265220... |
correct output |
---|
7364359200.7228123750537633895... |
user output |
---|
7364359200.722812375053763 |
Test 34
Verdict: ACCEPTED
input |
---|
6 -54250287 -57195506 925370083 ... |
correct output |
---|
6070544873.2142193284817039966... |
user output |
---|
6070544873.214219328481704 |
Test 35
Verdict: ACCEPTED
input |
---|
6 717786754 -23244255 -670216484... |
correct output |
---|
6236901804.9330618907697498798... |
user output |
---|
6236901804.933061890304089 |
Test 36
Verdict: ACCEPTED
input |
---|
6 -747595481 -560868740 20781968... |
correct output |
---|
6206348638.7408930636011064052... |
user output |
---|
6206348638.740893063601106 |
Test 37
Verdict: ACCEPTED
input |
---|
6 369551931 -830851741 -63146575... |
correct output |
---|
7466232851.6345729152671992778... |
user output |
---|
7466232851.634572915732861 |
Test 38
Verdict: ACCEPTED
input |
---|
7 -503438465 -401188031 -2915208... |
correct output |
---|
7182008964.6697172718122601509... |
user output |
---|
7182008964.66971727181226 |
Test 39
Verdict: ACCEPTED
input |
---|
7 -774852389 498112692 -73382627... |
correct output |
---|
7322574754.7929240637458860874... |
user output |
---|
7322574754.792924063280225 |
Test 40
Verdict: ACCEPTED
input |
---|
7 -745557241 -362230062 11872950... |
correct output |
---|
7345290128.8702740180306136608... |
user output |
---|
7345290128.870274018030614 |
Test 41
Verdict: ACCEPTED
input |
---|
7 -280510503 487323735 82609299 ... |
correct output |
---|
8284167601.0197063554078340530... |
user output |
---|
8284167601.019706354942173 |
Test 42
Verdict: ACCEPTED
input |
---|
7 -194568921 -912512861 44703011... |
correct output |
---|
9098246106.3207166725769639015... |
user output |
---|
9098246106.320716672576964 |
Test 43
Verdict: ACCEPTED
input |
---|
8 383287698 969195218 -182348842... |
correct output |
---|
7016551085.8444829522632062435... |
user output |
---|
7016551085.844482952728868 |
Test 44
Verdict: ACCEPTED
input |
---|
8 -385704087 -937741013 -3077950... |
correct output |
---|
8127710933.8054637983441352844... |
user output |
---|
8127710933.805463798344135 |
Test 45
Verdict: ACCEPTED
input |
---|
8 844450667 -871888619 -19960889... |
correct output |
---|
8213584640.6935460437089204788... |
user output |
---|
8213584640.693546044174582 |
Test 46
Verdict: ACCEPTED
input |
---|
8 -466328566 481082051 -33685140... |
correct output |
---|
9423990911.6089521860703825950... |
user output |
---|
9423990911.608952187001705 |
Test 47
Verdict: ACCEPTED
input |
---|
8 -917189424 -579600323 67525298... |
correct output |
---|
8227519630.3055775831453502178... |
user output |
---|
8227519630.305577583611012 |
Test 48
Verdict: ACCEPTED
input |
---|
9 -31221656 -526597392 -52535813... |
correct output |
---|
8856995290.3726284708827733993... |
user output |
---|
8856995290.372628471814096 |
Test 49
Verdict: ACCEPTED
input |
---|
9 -23884334 -938550432 -56172498... |
correct output |
---|
7357984723.6206405288539826870... |
user output |
---|
7357984723.620640528853983 |
Test 50
Verdict: ACCEPTED
input |
---|
9 -114003248 747828772 -69571861... |
correct output |
---|
7938964098.6173283923417329788... |
user output |
---|
7938964098.617328392807394 |
Test 51
Verdict: ACCEPTED
input |
---|
9 166708726 -263032442 565409766... |
correct output |
---|
7766653103.2631514174863696098... |
user output |
---|
7766653103.263151418417692 |
Test 52
Verdict: ACCEPTED
input |
---|
9 -325935302 409170424 652212820... |
correct output |
---|
8170515916.9658243129961192607... |
user output |
---|
8170515916.965824312996119 |
Test 53
Verdict: ACCEPTED
input |
---|
10 178568022 273124119 535857466 ... |
correct output |
---|
8231356926.8400429780595004558... |
user output |
---|
8231356926.840042977593839 |
Test 54
Verdict: ACCEPTED
input |
---|
10 -104452078 546885062 -99975436... |
correct output |
---|
9390756029.7148792939260601997... |
user output |
---|
9390756029.714879291132092 |
Test 55
Verdict: ACCEPTED
input |
---|
10 -63708076 -602539257 -94432385... |
correct output |
---|
8497255968.9021178991533815860... |
user output |
---|
8497255968.902117899153382 |
Test 56
Verdict: ACCEPTED
input |
---|
10 182829493 -848119476 520735868... |
correct output |
---|
9795917686.1810622680932283401... |
user output |
---|
9795917686.181062268093228 |
Test 57
Verdict: ACCEPTED
input |
---|
10 934069847 175172315 -629139614... |
correct output |
---|
10107572824.729460356757044792... |
user output |
---|
10107572824.72946035582572 |
Test 58
Verdict: ACCEPTED
input |
---|
10 -523273295 -881501593 86988338... |
correct output |
---|
9378626642.9278714880347251892... |
user output |
---|
9378626642.927871487103403 |
Test 59
Verdict: ACCEPTED
input |
---|
10 917402565 -287078799 -55030325... |
correct output |
---|
9067761971.7593543389812111854... |
user output |
---|
9067761971.759354338981211 |
Test 60
Verdict: ACCEPTED
input |
---|
10 -836129193 -511793054 67486286... |
correct output |
---|
9294216739.0473321685567498207... |
user output |
---|
9294216739.04733216855675 |
Test 61
Verdict: ACCEPTED
input |
---|
10 875675361 -976131926 -48580743... |
correct output |
---|
10188158256.107221888378262519... |
user output |
---|
10188158256.10722188837826 |
Test 62
Verdict: ACCEPTED
input |
---|
10 -977721665 -217325906 77767487... |
correct output |
---|
9173124717.6331664901226758956... |
user output |
---|
9173124717.633166489191353 |