QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369771#6302. Mapucup-team1191#AC ✓9ms4024kbC++202.2kb2024-03-28 17:46:132024-03-28 17:46:15

Judging History

你现在查看的是最新测评结果

  • [2024-03-28 17:46:15]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:4024kb
  • [2024-03-28 17:46:13]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)

struct vect {
    ld x, y;

    vect() = default;
    vect(ld x, ld y) : x(x), y(y) {}

    vect operator-(const vect& other) const {
        return vect(x - other.x, y - other.y);
    }

    ld operator*(const vect& other) const {
        return x * other.x + y * other.y;
    }

    ld len() const {
        return hypotl(x, y);
    }

    vect operator*(ld cf) const {
        return vect(x * cf, y * cf);
    }

    vect operator+(const vect& other) const {
        return vect(x + other.x, y + other.y);
    }
};

istream& operator>>(istream& in, vect& a) {
    int x, y;
    in >> x >> y;
    a.x = x;
    a.y = y;
    return in;
}

ostream& operator<<(ostream& out, const vect& a) {
    return out << a.x << " " << a.y;
}

void solve() {
    vector<vect> v1(4), v2(4);
    for (int i = 0; i < 4; i++) {
        cin >> v1[i];
    }
    for (int i = 0; i < 4; i++) {
        cin >> v2[i];
    }

    ld lenx = (v1[0] - v1[1]).len();
    ld leny = (v1[2] - v1[1]).len();

    auto transform = [&](const vect& pt) {
        ld cx = ((pt - v1[1]) * (v1[0] - v1[1])) / (lenx * lenx);
        ld cy = ((pt - v1[1]) * (v1[2] - v1[1])) / (leny * leny);
        return v2[1] + (v2[0] - v2[1]) * cx + (v2[2] - v2[1]) * cy;
    };

    vect s, t;
    cin >> s >> t;

    int k, n;
    cin >> k >> n;

    vector<vect> seq1(n + 1);
    seq1[0] = s;
    for (int i = 1; i <= n; i++) {
        seq1[i] = transform(seq1[i - 1]);
    }
    vector<vect> seq2(n + 1);
    seq2[0] = t;
    for (int i = 1; i <= n; i++) {
        seq2[i] = transform(seq2[i - 1]);
    }

    ld ans = 1e18;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            ans = min(ans, (seq1[i] - seq2[j]).len() + (ld)k * (i + j));
        }
    }

    cout << ans << "\n";
}

int main() {
#ifdef ONPC
    freopen("input", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cout << fixed << setprecision(20);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3856kb

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.00000000000000000000
1.22726233524302897476

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 8ms
memory: 3872kb

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.50065749974155818701
12.22973107892215767056
13.00000000000000000000
17.48853290037507947699
13.34166406412633371255
7.61577310586390828547
23.40939982143925021836
7.28010988928051827130
21.28003773408388471164
59.77602209257912379073
4.12310562561766054965
79.64923100695950849981
65.0691939399897...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 9ms
memory: 3856kb

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.00000000000000000000
25.48363797558436765964
40.22437072223753259936
18.38477631085023563523
9.21954445729288731004
18.02775637731994646563
43.11406302628035583369
52.88704435234900601975
45.54119014694280033473
55.00099997500124992394
37.00000000000000000000
12.04159457879229548020
24.3310501211...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 8ms
memory: 3920kb

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.24695047554424263622
8.00000000000000000000
45.92695228684294729213
135.11846653955187630425
131.97348218486924503745
40.34966595395349910069
15.32134772871250819742
77.77227503502051721151
66.73881303589937066811
8.00026665481586816888
116.80644603167309714120
12.58829001561597414009
170.7856302...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 7ms
memory: 3860kb

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.35008143300875130613
51.96763232093798016292
21.46869792814677587248
38.83793207646776732278
84.24818742830802746624
77.92945527847605839689
47.00000000000000000000
74.11549372591249720127
86.46710488042168901018
35.11409973215887532841
3.60555127546398929313
97.41663102366043124059
24.6060569657...

result:

ok 100 numbers

Test #6:

score: 0
Accepted
time: 8ms
memory: 4024kb

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.05586353287904721743
290.42570045093640701550
258.28240031306625207330
743.73718476354266521122
341.05278183882329975929
400.56668366243277398797
172.04079934095691307994
27.77089460983787016189
294.82588015208115367338
508.06591068887296425149
501.78182509931544949544
666.80506896693579349522
1...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 8ms
memory: 3980kb

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.43354954612926129009
96.88092305392856839336
530.33008588991064330420
44.01136216933077385111
64.31336536618194144044
7.39289366612612396145
34.56781020746237360897
148.85016074299253306668
350.33813591614860455392
329.22516277982119758949
68.86476510887299042063
32.82438317461281856308
244.6957...

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 6ms
memory: 3980kb

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.47965700263067832798
977.20932282056736911668
94.48632505936063130658
307.00651458886014980032
1245.62955970063587762819
532.00000000000000000000
369.04877726392753894968
19.55402431723254504277
1509.00000000000000000000
275.09426721132933577052
4242.19335151470814970764
465.65625140881037360985
...

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 8ms
memory: 3876kb

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.57488648929182007558
999.68927767812956824978
6231.52966774611448608212
550.94788609503487702979
182.54412465860600588152
5374.29679120906012501635
825.72578109665644352511
1653.20742916917174003544
2777.10964853748617708895
166.65302380610115770554
1747.00457927276195224664
651.11135760329046806...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 9ms
memory: 3884kb

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.64331697709323806822
41.43669871020132318071
39.20655561573370294706
11.18033988749894848229
49.72926703662542420592
26.92582403567252015593
50.93132631298737345027
10.29405582016538875552
117.88553770501282317446
8.60232526704262677204
48.46648326421053628102
21.09502310972898649934
24.038404810...

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 8ms
memory: 3924kb

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.51754858215628973817
2119.67478013969855243914
1638.60149419540855153521
144.69968901141425743351
1706.29921174452870347160
2671.66801829868076145758
1442.32485938501385869248
2909.93127066602725983024
5311.38635386280292749461
7894.84420365595308322071
2950.72143720819570011926
1405.1972795871...

result:

ok 100 numbers

Test #12:

score: 0
Accepted
time: 4ms
memory: 3972kb

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.00394381264997889502
344430.70876447703875555817
597464.94716012225762824528
57512.00002125127506502622
180112.50498394933897827741
254594.18946546364709604404
13301.83436763094007559971
246235.74134150387388331183
17086.95373669631025670412
168329.00118814939371247874
580568.27843760117031024...

result:

ok 100 numbers

Test #13:

score: 0
Accepted
time: 6ms
memory: 3916kb

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.52377363915134898462
126504.99951860885083476660
57518.29369733294659994272
318943.66370254167506459453
169769.25000566878962615647
1497.13389306734866524007
23459.32499196507475858198
853.34781609536249669112
28.35141184590380106917
7526.10652403645082797468
36705.81656903984475093239
575.015321...

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 7ms
memory: 3920kb

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.58456291068387855603
404181.38882437424769022982
311311.52891757799466176948
271785.62453706045855028606
319158.19183909411287913827
77725.02554349504788433478
103690.24156928994485582507
33781.00427755219950043397
16708.60835018883312663718
262422.76822714907106615101
176381.84309332976238238...

result:

ok 100 numbers