QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#220566 | #6302. Map | ucup-team1883# | AC ✓ | 10ms | 3308kb | C++17 | 1.5kb | 2023-10-20 15:34:07 | 2023-10-20 15:34:07 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
using namespace std;
#define LOG(f...) fprintf(stderr, f)
using db = long double;
struct pt {
db x, y;
};
pt operator+(pt a, pt b) { return {a.x + b.x, a.y + b.y}; }
pt operator-(pt a, pt b) { return {a.x - b.x, a.y - b.y}; }
pt operator*(db l, pt a) { return {l * a.x, l * a.y}; }
db dot(pt a, pt b) { return a.x * b.x + a.y * b.y; }
db len(pt a) { return hypot(a.x, a.y); }
pt A[4], B[4];
pt F(pt P) {
pt i = A[1] - A[0], j = A[3] - A[0];
i = ((db)1 / len(i) / len(i)) * i;
j = ((db)1 / len(j) / len(j)) * j;
db ci = dot((P - A[0]), i);
db cj = dot((P - A[0]), j);
return B[0] + ci * (B[1] - B[0]) + cj * (B[3] - B[0]);
}
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int T;
scanf("%d", &T);
while (T--) {
for (auto &x : A)
scanf("%Lf%Lf", &x.x, &x.y);
for (auto &x : B)
scanf("%Lf%Lf", &x.x, &x.y);
pt S, T;
scanf("%Lf%Lf%Lf%Lf", &S.x, &S.y, &T.x, &T.y);
db k, n;
scanf("%Lf%Lf", &k, &n);
vector<pt> fS(n + 1), fT(n + 1);
fS[0] = S; fT[0] = T;
for (int i = 1; i <= n; ++i)
fS[i] = F(fS[i - 1]);
for (int i = 1; i <= n; ++i)
fT[i] = F(fT[i - 1]);
db ans = INFINITY;
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= n - i; ++j)
ans = min(ans, k * (i + j) + len(fS[i] - fT[j]));
printf("%.18Lg\n", ans);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3096kb
input:
2 0 0 0 2 4 2 4 0 0 0 0 1 2 1 2 0 2 1 4 2 1 1 0 0 0 3 6 3 6 0 0 1 1 0 3 2 2 3 0 0 4 2 0 3
output:
1 1.22726233524302897
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 9ms
memory: 3232kb
input:
100 -133 -128 -109 -134 -85 -38 -109 -32 -95 -37 -100 -35 -108 -55 -103 -57 -119 -130 -112 -44 2 73 5 -100 5 -8 1 -8 1 -100 1 -60 1 -14 3 -14 3 -60 3 -84 1 -20 2 53 -58 -78 -66 -78 -66 -34 -58 -34 -58 -34 -66 -34 -66 -78 -58 -78 -63 -50 -63 -37 4 54 52 -148 116 -148 116 -52 52 -52 53 -103 53 -71 101...
output:
9.50065749974155819 12.2297310789221577 13 17.4885329003750795 13.3416640641263337 7.61577310586390829 23.4093998214392502 7.28010988928051827 21.2800377340838847 59.7760220925791238 4.12310562561766055 79.6492310069595085 65.0691939399897592 14.1421356237309505 41.8246155034797542 16.05624518489698...
result:
ok 100 numbers
Test #3:
score: 0
Accepted
time: 10ms
memory: 3124kb
input:
100 -173 -113 -120 -113 -120 -115 -173 -115 -173 -115 -120 -115 -120 -113 -173 -113 -162 -114 -152 -114 99 57 6 23 -75 4 -56 -77 25 -58 0 -58 -51 -69 -62 -18 -11 -7 -22 -56 -42 -25 19 27 -98 -115 -150 -147 -158 -134 -106 -102 -150 -147 -98 -115 -106 -102 -158 -134 -103 -111 -136 -134 25 50 136 -92 1...
output:
10 25.4836379755843677 40.2243707222375326 18.3847763108502356 9.21954445729288731 18.0277563773199465 43.1140630262803558 52.887044352349006 45.5411901469428003 55.0009999750012499 37 12.0415945787922955 24.3310501211928788 18.1107702762748333 7.56326275327950407 2.2360679774997897 8.23606797749978...
result:
ok 100 numbers
Test #4:
score: 0
Accepted
time: 9ms
memory: 3188kb
input:
100 -12 -206 72 -188 135 -482 51 -500 19 -301 23 -301 23 -315 19 -315 88 -368 28 -248 14 87 -221 -566 -467 -566 -467 -565 -221 -565 -221 -566 -467 -566 -467 -565 -221 -565 -297 -566 -289 -566 274 18 -264 759 -339 609 -129 504 -54 654 -208 580 -208 655 -103 655 -103 580 -196 664 -211 596 8 64 -111 -3...
output:
34.2469504755442426 8 45.9269522868429473 135.118466539551876 131.973482184869245 40.3496659539534991 15.3213477287125082 77.7722750350205172 66.7388130358993707 8.00026665481586817 116.806446031673097 12.5882900156159741 170.785630266285701 131.962750429094417 8.73808997516030717 17.464249196572980...
result:
ok 100 numbers
Test #5:
score: 0
Accepted
time: 8ms
memory: 3244kb
input:
100 -235 -704 133 -704 133 -720 -235 -720 -224 -712 -40 -712 -40 -704 -224 -704 15 -711 76 -718 4 74 -467 574 -475 596 -123 724 -115 702 -274 662 -270 652 -430 588 -434 598 -458 588 -241 657 15 31 380 -3 532 -343 787 -229 635 111 503 -71 639 -163 708 -61 572 31 533 -189 613 -137 3 58 -460 -7 -488 -7...
output:
31.3500814330087513 51.9676323209379802 21.4686979281467759 38.8379320764677673 84.2481874283080275 77.9294552784760584 47 74.1154937259124972 86.467104880421689 35.1140997321588753 3.60555127546398929 97.4166310236604312 24.606056965764579 56.7733594327239125 6.99853461941493523 13.4536240470737103...
result:
ok 100 numbers
Test #6:
score: 0
Accepted
time: 9ms
memory: 3160kb
input:
100 -1201 2822 -1197 2814 -3437 1694 -3441 1702 -3119 1860 -3117 1856 -1997 2416 -1999 2420 -1419 2709 -2491 2174 48 76 -2515 285 -2547 306 -1308 2194 -1276 2173 -2255 683 -2260 686 -2083 981 -2078 978 -1572 1753 -1392 2015 121 28 -1216 1209 -1498 -1141 -1598 -1129 -1316 1221 -1494 -823 -1494 -447 -...
output:
264.055863532879047 290.425700450936407 258.282400313066252 743.737184763542665 341.0527818388233 400.566683662432774 172.040799340956913 27.7708946098378704 294.825880152081154 508.065910688872964 501.781825099315449 666.805068966935793 180.069431053691065 193.610433603150634 1507.00298606207148 25...
result:
ok 100 numbers
Test #7:
score: 0
Accepted
time: 9ms
memory: 3228kb
input:
100 1411 -2755 603 -3563 623 -3583 1431 -2775 716 -3477 1120 -3073 1110 -3063 706 -3467 1210 -2959 1339 -2830 2319 39 4528 -3417 4286 -4055 1908 -3153 2150 -2515 2094 -2892 2094 -3090 2832 -3090 2832 -2892 2257 -2993 4389 -3736 17 22 -180 -1673 -2172 -3665 -2164 -3673 -172 -1681 -284 -1792 -2027 -35...
output:
182.433549546129261 96.8809230539285684 530.330085889910643 44.0113621693307739 64.3133653661819414 7.39289366612612396 34.5678102074623736 148.850160742992533 350.338135916148604 329.225162779821198 68.8647651088729904 32.8243831746128186 244.695729427384981 685.968837711980812 141.362747995939058 ...
result:
ok 100 numbers
Test #8:
score: 0
Accepted
time: 10ms
memory: 3308kb
input:
100 11928 -18111 8928 -17411 11056 -8291 14056 -8991 11043 -10811 10793 -10111 12921 -9351 13171 -10051 10491 -14092 11923 -12413 10 92 11869 -4371 3539 5429 1299 3525 9629 -6275 8302 -3064 3647 2571 4935 3635 9590 -2000 2384 2680 3466 2644 181 91 4001 -10187 4001 -10897 9 -10897 9 -10187 838 -10629...
output:
87.4796570026306783 977.209322820567369 94.4863250593606313 307.00651458886015 1245.62955970063588 532 369.048777263927539 19.554024317232545 1509 275.094267211329336 4242.19335151470815 465.656251408810374 3478.30424206018254 1754.35600720036297 1804.46692758593302 21.3531426606265059 415.415534624...
result:
ok 100 numbers
Test #9:
score: 0
Accepted
time: 9ms
memory: 3300kb
input:
100 10303 -4099 19487 -8131 19703 -7639 10519 -3607 18394 -7495 18842 -7271 18854 -7295 18406 -7519 15852 -6248 15950 -6389 38 10 13132 -3411 17416 3393 15634 4515 11350 -2289 13143 -873 15411 3411 16533 2817 14265 -1467 16515 2577 16017 1561 198 94 -5480 10872 -6297 11294 -11361 1490 -10544 1068 -1...
output:
84.5748864892918201 999.689277678129568 6231.52966774611449 550.947886095034877 182.544124658606006 5374.29679120906013 825.725781096656443 1653.20742916917174 2777.10964853748618 166.653023806101158 1747.00457927276195 651.111357603290468 242.210006732268284 34.266895846221599 286.790864568591166 2...
result:
ok 100 numbers
Test #10:
score: 0
Accepted
time: 10ms
memory: 3120kb
input:
100 0 -30 84 12 126 -72 42 -114 0 -30 84 12 126 -72 42 -114 91 -41 100 -55 96 93 168 110 148 150 48 100 68 60 48 100 68 60 168 110 148 150 61 96 102 90 8 2 -123 129 -60 174 -15 111 -78 66 -15 111 -78 66 -123 129 -60 174 -44 115 -104 132 27 3 27 42 15 54 -75 -36 -63 -48 -63 -48 -75 -36 15 54 27 42 -4...
output:
16.6433169770932381 41.4366987102013232 39.206555615733703 11.1803398874989485 49.7292670366254242 26.9258240356725202 50.9313263129873735 10.2940558201653888 117.885537705012823 8.60232526704262677 48.4664832642105363 21.0950231097289865 24.0384048104052974 16 48.5489443757534238 26.061756859551125...
result:
ok 100 numbers
Test #11:
score: 0
Accepted
time: 9ms
memory: 3308kb
input:
100 9725 6731 9725 11971 14965 11971 14965 6731 9725 6731 9725 11971 14965 11971 14965 6731 10293 11185 10445 9833 488 10 3833 -4831 6913 -4271 8443 -12686 5363 -13246 6913 -4271 3833 -4831 5363 -13246 8443 -12686 5209 -4960 7133 -6409 1 88 -5891 -6066 -8365 -6066 -8365 -8540 -5891 -8540 -8365 -6066...
output:
1360.51754858215629 2119.67478013969855 1638.60149419540855 144.699689011414257 1706.2992117445287 2671.66801829868076 1442.32485938501386 2909.93127066602726 5311.38635386280293 7894.84420365595308 2950.7214372081957 1405.19727958716684 8052.78597753597323 436.084854128184553 1910.19014712379156 15...
result:
ok 100 numbers
Test #12:
score: 0
Accepted
time: 6ms
memory: 3172kb
input:
100 1432065 -1359744 1432065 -1359796 610089 -1359796 610089 -1359744 610089 -1359744 610089 -1359796 1432065 -1359796 1432065 -1359744 1413145 -1359747 670086 -1359765 306 12 -630899 -570942 344981 -570942 344981 -567164 -630899 -567164 -630899 -567164 344981 -567164 344981 -570942 -630899 -570942 ...
output:
41383.00394381265 344430.708764477039 597464.947160122258 57512.0000212512751 180112.504983949339 254594.189465463647 13301.8343676309401 246235.741341503874 17086.9537366963103 168329.001188149394 580568.27843760117 120047.475965045275 24722.5759377941845 252882.798719090421 366.882341145875687 108...
result:
ok 100 numbers
Test #13:
score: 0
Accepted
time: 10ms
memory: 3220kb
input:
100 -240497 1168822 -365542 931192 504344 473443 629389 711073 226221 683190 167481 688085 185400 903113 244140 898218 -192129 1110656 34450 941656 2 25 1729381 25950 1512625 519672 1528369 526584 1745125 32862 1536820 492965 1580974 388601 1584302 390009 1540148 494373 1660204 207517 1601591 344571...
output:
33.5237736391513944 126504.999518608851 57518.2936973329466 318943.663702541675 169769.25000566879 1497.13389306734867 23459.3249919650747 853.347816095362503 28.3514118459038011 7526.10652403645083 36705.8165690398448 575.01532167522363 4025.08488222493308 31458.0236664670338 316549.014556987683 52...
result:
ok 100 numbers
Test #14:
score: 0
Accepted
time: 8ms
memory: 3240kb
input:
100 -889209 606569 -191736 1436894 638589 739421 -58884 -90904 -58884 -90904 638589 739421 -191736 1436894 -889209 606569 -486300 891465 -464854 988546 79 18 -1226546 957048 -712144 1926170 -590407 1861553 -1104809 892431 -712144 1926170 -1226546 957048 -1104809 892431 -590407 1861553 -807239 146415...
output:
99421.5845629106839 404181.388824374248 311311.528917577995 271785.624537060459 319158.191839094113 77725.0255434950479 103690.241569289945 33781.0042775521995 16708.6083501888331 262422.768227149071 176381.843093329762 159818.483940375307 451836.634220813617 291664.040180887799 406095.266612404632 ...
result:
ok 100 numbers