QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#180782#6302. Mapucup-team045AC ✓1ms4064kbC++204.0kb2023-09-16 12:36:202023-09-16 12:36:20

Judging History

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

  • [2023-09-16 12:36:20]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4064kb
  • [2023-09-16 12:36:20]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
using LL = long long;
using point_t = long double; //全局数据类型,可修改为 long long 等

const point_t eps = 1e-8;
const long double PI = acosl(-1);
//const long double PI = numbers::pi_v<long double>;

// 点与向量
template <typename T>
struct point{
    T x, y;

    void input(){
        int xx, yy;
        cin >> xx >> yy;
        x = xx, y = yy;
    }

    bool operator==(const point &a) const { return (abs(x - a.x) <= eps && abs(y - a.y) <= eps); }
    bool operator<(const point &a) const{
        if (abs(x - a.x) <= eps)
            return y < a.y - eps;
        return x < a.x - eps;
    }
    bool operator>(const point &a) const { return !(*this < a || *this == a); }
    point operator+(const point &a) const { return {x + a.x, y + a.y}; }
    point operator-(const point &a) const { return {x - a.x, y - a.y}; }
    point operator-() const { return {-x, -y}; }
    point operator*(const T k) const { return {k * x, k * y}; }
    point operator/(const T k) const { return {x / k, y / k}; }
    T operator*(const point &a) const { return x * a.x + y * a.y; } // 点积
    T operator^(const point &a) const { return x * a.y - y * a.x; } // 叉积,注意优先级
    int toleft(const point &a) const
    {
        const auto t = (*this) ^ a;
        return (t > eps) - (t < -eps);
    }                                                             // to-left 测试
    T len2() const { return (*this) * (*this); }                  // 向量长度的平方
    T dis2(const point &a) const { return (a - (*this)).len2(); } // 两点距离的平方

    // 涉及浮点数
    long double len() const { return sqrtl(len2()); }                                                                      // 向量长度
    long double dis(const point &a) const { return sqrtl(dis2(a)); }                                                       // 两点距离
    long double ang(const point &a) const { return acosl(max(-1.0l, min(1.0l, ((*this) * a) / (len() * a.len())))); }      // 向量夹角
    point rot(const long double rad) const { return {x * cosl(rad) - y * sinl(rad), x * sinl(rad) + y * cosl(rad)}; }          // 逆时针旋转(给定角度)
    point rot(const long double cosr, const long double sinr) const { return {x * cosr - y * sinr, x * sinr + y * cosr}; } // 逆时针旋转(给定角度的正弦与余弦)
};

using Point = point<point_t>;

struct Plane{
    Point o, vx, vy;
    long double len1, len2;  
}r[2];

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int T;
    cin >> T;
    while(T--){
        for(int i = 0; i < 2; i++){
            Point p[4];
            for(int j = 0; j < 4; j++){
                p[j].input();
            }
            long double len1 = (p[3] - p[0]).len();
            long double len2 = (p[1] - p[0]).len();
            r[i] = {p[0], (p[3] - p[0]) / len1, (p[1] - p[0]) / len2, len1, len2};
        }

        auto get = [&](Point p){
            auto v = p - r[0].o;
            long double t1 = v * r[0].vx / r[0].len1 * r[1].len1;
            long double t2 = v * r[0].vy / r[0].len2 * r[1].len2;
            Point ret = r[1].o + r[1].vx * t1 + r[1].vy * t2;
            return ret;
        };

        Point s, t;
        s.input(), t.input();
        int k, n;
        cin >> k >> n;

        vector<Point> path1{s}, path2{t};
        for(int i = 0; i <= n; i++){
            path1.push_back(get(path1.back()));
            path2.push_back(get(path2.back()));
        }
        long double ans = 1e18;
        for(int i = 0; i <= n; i++){
            for(int j = 0; i + j <= n; j++){
                ans = min(ans, 1.0L * k * (i + j) + path1[i].dis(path2[j]));
            }
        }
        cout << ans << '\n';
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4036kb

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.22726233524302897487

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 3944kb

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.28003773408388470817
59.77602209257912379420
4.12310562561766054965
79.64923100695950849981
65.0691939399897...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3840kb

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.48363797558436765790
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: 1ms
memory: 3848kb

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.92695228684294729560
135.11846653955187630425
131.97348218486924503745
40.34966595395349910069
15.32134772871250819916
77.77227503502051721151
66.73881303589937066811
8.00026665481586816888
116.80644603167309714120
12.58829001561597414529
170.7856302...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 3848kb

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.46869792814677587421
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: 1ms
memory: 3812kb

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.42570045093640698775
258.28240031306625212881
743.73718476354266521122
341.05278183882329975929
400.56668366243277412675
172.04079934095691307994
27.77089460983787036139
294.82588015208115372889
508.06591068887296430701
501.78182509931544949544
666.80506896693579349522
1...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 3840kb

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: 1ms
memory: 3912kb

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.20932282056736928322
94.48632505936063130658
307.00651458886014980032
1245.62955970063587762819
532.00000000000000000000
369.04877726392753894968
19.55402431723254504277
1509.00000000000000000000
275.09426721132933613134
4242.19335151470814970764
465.65625140881037433149
...

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 0ms
memory: 3896kb

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.68927767812956847182
6231.52966774611448608212
550.94788609503487686325
182.54412465860600547907
5374.29679120906012501635
825.72578109665644330306
1653.20742916917174003544
2777.10964853748617708895
166.65302380610115759452
1747.00457927276195224664
651.11135760329046806...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 1ms
memory: 3768kb

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.20655561573370295053
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: 1ms
memory: 3900kb

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: 0ms
memory: 3756kb

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.94716012225757140186
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: 1ms
memory: 3952kb

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.52377363915138297132
126504.99951860885084187203
57518.29369733294659994272
318943.66370254167506459453
169769.25000566878962615647
1497.13389306734866990301
23459.32499196507468042228
853.34781609536251706372
28.35141184590379779228
7526.10652403645082797468
36705.81656903984475093239
575.015321...

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 1ms
memory: 4064kb

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