QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708702#2455. Retribution!Tenshi#AC ✓220ms35280kbC++233.1kb2024-11-04 04:02:442024-11-04 04:02:44

Judging History

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

  • [2024-11-04 04:02:44]
  • 评测
  • 测评结果:AC
  • 用时:220ms
  • 内存:35280kb
  • [2024-11-04 04:02:44]
  • 提交

answer

#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <tuple>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define sz(x) (long long)(x).size()


bool comp(pair<long long, pair<int, int>> a, pair<long long, pair<int, int>> b) {
    if (a.first < b.first) return true;
    if (a.first > b.first) return false;
    if (a.second.first < b.second.first) return true;
    if (a.second.first > b.second.first) return false;
    if (a.second.second < b.second.second) return true;
    if (a.second.second > b.second.second) return false;
    assert(1==0);
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int m, n, p;
    cin >> n >> m >> p;

    vector<tuple<long long, long long, int>> judges;
    for (int i = 0 ; i < n; i++) {
        long long x, y;
        cin >> x >> y;
        judges.emplace_back(x, y, i);
    }

    vector<tuple<long long, long long, int>> tar;
    for (int i = 0 ; i < m; i++) {
        long long x, y;
        cin >> x >> y;
        tar.emplace_back(x, y, i);
    }

    vector<tuple<long long, long long, int>> feather;
    for (int i = 0 ; i < p; i++) {
        long long x, y;
        cin >> x >> y;
        feather.emplace_back(x, y, i);
    }

    vector<bool> judgeAssigned(n, false), tarAssigned(m, false), featherAssigned(p, false);
    vector<pair<long long, pair<int, int>>> d;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            d.push_back({(get<0>(judges[i])-get<0>(tar[j]))*(get<0>(judges[i])-get<0>(tar[j])) + 
                           (get<1>(judges[i])-get<1>(tar[j]))*(get<1>(judges[i])-get<1>(tar[j])), 
                            {i, j}});
        }
    }
    sort(d.begin(), d.end(), comp);
    long double out = 0;
    rep(i, sz(d)) {
        if (judgeAssigned[d[i].second.first] or tarAssigned[d[i].second.second]) {
            continue;
        }
        // cout << d[i].second.first << ' ' << d[i].second.second << endl; 
        out+=sqrt(d[i].first);
        judgeAssigned[d[i].second.first] = true;
        tarAssigned[d[i].second.second] = true;
    }

    d = vector<pair<long long, pair<int, int>>>();
    judgeAssigned = vector<bool>(n, false);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < p; j++) {
            d.push_back({(get<0>(judges[i])-get<0>(feather[j]))*(get<0>(judges[i])-get<0>(feather[j])) + 
                           (get<1>(judges[i])-get<1>(feather[j]))*(get<1>(judges[i])-get<1>(feather[j])), 
                            {i, j}});
        }
    }
    sort(d.begin(), d.end(), comp);
    rep(i, sz(d)) {
        if (judgeAssigned[d[i].second.first] or featherAssigned[d[i].second.second]) {
            continue;
        }
        out+=sqrt(d[i].first);
        // cout << d[i].second.first << ' ' << d[i].second.second << endl; 

        judgeAssigned[d[i].second.first] = true;
        featherAssigned[d[i].second.second] = true;
    }

    cout << setprecision(10) << fixed << out << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 2 2
1 0
2 0
0 0
3 0
1 1
2 1

output:

4.0000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #2:

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

input:

1 1 1
5875 3435
-743 8951
2325 7352

output:

13901.6854602582

result:

ok found '13901.6854603', expected '13901.6854603', error '0.0000000'

Test #3:

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

input:

2 2 2
0 0
10 0
6 0
20 0
6 0
20 0

output:

48.0000000000

result:

ok found '48.0000000', expected '48.0000000', error '0.0000000'

Test #4:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
5 0
0 -5
-5 0
0 5
5 0
0 -5
0 5
-5 0

output:

157.8224594073

result:

ok found '157.8224594', expected '157.8224594', error '0.0000000'

Test #5:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
5 0
-5 0
0 -5
0 5
5 0
-5 0
0 5
0 -5

output:

150.8502157847

result:

ok found '150.8502158', expected '150.8502158', error '0.0000000'

Test #6:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
5 0
0 5
0 -5
-5 0
5 0
0 5
-5 0
0 -5

output:

149.3111861943

result:

ok found '149.3111862', expected '149.3111862', error '0.0000000'

Test #7:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
0 -5
5 0
-5 0
0 5
0 -5
5 0
0 5
-5 0

output:

145.4617796323

result:

ok found '145.4617796', expected '145.4617796', error '0.0000000'

Test #8:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
0 -5
-5 0
5 0
0 5
0 -5
-5 0
0 5
5 0

output:

140.0285656000

result:

ok found '140.0285656', expected '140.0285656', error '0.0000000'

Test #9:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
0 -5
0 5
5 0
-5 0
0 -5
0 5
-5 0
5 0

output:

150.8949936646

result:

ok found '150.8949937', expected '150.8949937', error '0.0000000'

Test #10:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
-5 0
5 0
0 -5
0 5
-5 0
5 0
0 5
0 -5

output:

126.0840783547

result:

ok found '126.0840784', expected '126.0840784', error '0.0000000'

Test #11:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
-5 0
0 -5
5 0
0 5
-5 0
0 -5
0 5
5 0

output:

126.0840783547

result:

ok found '126.0840784', expected '126.0840784', error '0.0000000'

Test #12:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
-5 0
0 5
5 0
0 -5
-5 0
0 5
0 -5
5 0

output:

126.0840783547

result:

ok found '126.0840784', expected '126.0840784', error '0.0000000'

Test #13:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
0 5
5 0
0 -5
-5 0
0 5
5 0
-5 0
0 -5

output:

136.9505064193

result:

ok found '136.9505064', expected '136.9505064', error '0.0000000'

Test #14:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
0 5
0 -5
5 0
-5 0
0 5
0 -5
-5 0
5 0

output:

136.9505064193

result:

ok found '136.9505064', expected '136.9505064', error '0.0000000'

Test #15:

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

input:

4 4 4
0 0
10 0
15 -15
1 40
0 5
-5 0
5 0
0 -5
0 5
-5 0
0 -5
5 0

output:

136.9505064193

result:

ok found '136.9505064', expected '136.9505064', error '0.0000000'

Test #16:

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

input:

5 5 5
0 0
10 10
20 20
30 30
40 40
10 0
20 10
30 20
40 30
50 40
0 10
10 20
20 30
30 40
40 50

output:

100.0000000000

result:

ok found '100.0000000', expected '100.0000000', error '0.0000000'

Test #17:

score: 0
Accepted
time: 21ms
memory: 6856kb

input:

200 500 500
9317 9422
967 -1586
4914 -1686
298 -2757
5733 7839
2366 -1911
-6760 -7344
-5277 -8055
-6719 1100
6048 9021
-2631 -1185
-9021 -2756
-871 -8829
5937 630
-4120 501
-2119 -4639
-3429 9773
-8790 -5080
-4588 -4404
-983 -4692
-2901 -7622
5147 1450
-6601 4971
5450 758
-4282 -8352
-3228 3634
-850...

output:

0.0000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #18:

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

input:

100 300 500
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 1058
9474 105...

output:

1320642.6357890903

result:

ok found '1320642.6357891', expected '1320642.6357891', error '0.0000000'

Test #19:

score: 0
Accepted
time: 124ms
memory: 29316kb

input:

600 1000 1000
-5279 9183
-5142 2199
1159 8000
6190 3760
-2235 -3115
-3717 -4337
2385 -9717
1979 2349
-670 -4911
-5219 -3475
6690 852
4558 -2037
-3487 -9769
488 -2979
-3320 -615
-6510 -6853
3865 -4778
3686 -2060
-8277 9430
5648 7885
-967 -1666
-4585 9127
2337 -5555
-2880 -3590
3781 36
-9745 3021
6773...

output:

470049.3302835419

result:

ok found '470049.3302835', expected '470049.3302835', error '0.0000000'

Test #20:

score: 0
Accepted
time: 20ms
memory: 6960kb

input:

100 1000 1000
922 9101
3100 1580
1294 -7721
-6165 -8516
394 -2688
-4818 -639
-5290 -6133
-5489 -8166
-2548 -7234
-3512 -3708
-7119 -2390
-6967 3042
-5045 -1628
-5421 8596
-1425 -8296
9360 -3574
-3753 -5373
4029 673
-2627 -9196
9349 -8286
1699 6300
-844 -2833
7124 -5145
-7703 8708
-3414 -5303
1485 -6...

output:

69604.3478112928

result:

ok found '69604.3478113', expected '69604.3478113', error '0.0000000'

Test #21:

score: 0
Accepted
time: 33ms
memory: 10504kb

input:

200 1000 1000
-1619 9114
1049 7500
-3000 769
2127 3934
-4197 -2177
-4642 -1231
-4641 -3114
-1673 -4935
-7150 1734
-7717 -9152
9270 -9497
1090 -2435
-6345 -8752
-5055 -4473
-5422 -1092
-4397 -4337
819 -2418
-1269 6057
-671 -973
-7312 -9971
-8873 2983
-3826 9566
8980 -8070
-2999 425
1329 -8142
-5555 -...

output:

129789.1443608198

result:

ok found '129789.1443608', expected '129789.1443608', error '0.0000000'

Test #22:

score: 0
Accepted
time: 60ms
memory: 16400kb

input:

300 1000 1000
-646 9131
-9706 -1483
3867 6807
257 -504
-2170 -5156
-4422 -1970
-212 -3491
6715 -5045
-561 -8015
-8399 1
1138 2045
-9372 7103
-3820 -1273
-979 3765
-1801 3338
2983 -9333
-1657 1701
-7891 -3596
2199 9306
-7712 157
-9746 -1164
-7127 -7702
-5085 615
-8928 2306
3108 -3074
5646 -8760
-6340...

output:

209890.4458796820

result:

ok found '209890.4458797', expected '209890.4458797', error '0.0000000'

Test #23:

score: 0
Accepted
time: 75ms
memory: 18716kb

input:

400 1000 1000
-3710 9154
-5103 -7506
-1414 -6528
-233 8516
329 -646
-4113 -3006
-2693 408
-2990 -773
-2657 -4130
-7566 -7185
-1567 -3583
6962 -6098
-4712 2644
-3954 1852
-2944 7753
-133 -1094
1769 914
-4395 2209
-336 -9072
2708 -558
-2288 -6969
1698 -6005
-5455 1453
-8888 -9955
-2742 -2192
-6673 559...

output:

286710.9630597472

result:

ok found '286710.9630597', expected '286710.9630597', error '0.0000000'

Test #24:

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

input:

500 1000 1000
-2737 9170
-3092 -3722
-1781 -490
-2102 -8690
2357 -3625
-3893 -3745
1736 32
-1837 -883
-8835 -1112
-1014 1969
-9699 7959
9267 -9327
-2187 -2645
121 -2676
677 -7818
-5520 -6090
-707 -7734
8984 -7444
2534 1207
2308 2336
-3162 1651
-1604 -3273
481 -2629
-7583 4692
-8196 2876
-2706 -3116
...

output:

395858.1495181320

result:

ok found '395858.1495181', expected '395858.1495181', error '0.0000000'

Test #25:

score: 0
Accepted
time: 149ms
memory: 31584kb

input:

700 1000 1000
4947 9196
-7193 -4647
-3136 -3511
-5519 -3791
5941 -2604
-3541 -4928
3034 -6698
-6971 -7187
-5272 4057
-9424 3848
3078 979
-152 -7513
7980 -4126
854 3952
-82 6589
-266 5151
8438 5411
-1611 -9443
912 -2348
8989 -6567
1228 -4983
-333 1525
4192 4287
1824 -4639
-4243 4431
3216 9158
-1758 -...

output:

637650.9744090197

result:

ok found '637650.9744090', expected '637650.9744090', error '0.0000000'

Test #26:

score: 0
Accepted
time: 175ms
memory: 32828kb

input:

800 1000 1000
-5351 9219
-2590 2097
-8416 -9612
6758 5229
-4327 1906
-3232 -5964
553 4435
-3910 4320
-7367 -4825
-8592 -3338
-6861 -4649
-3819 -714
-145 -209
-2121 2039
-8460 -8997
-3382 -6611
-8137 4624
1885 -3637
-1623 -725
6642 -7282
8685 9212
1259 -9544
-8945 5125
1864 -4133
2674 -1922
-9104 351...

output:

759351.8838631255

result:

ok found '759351.8838631', expected '759351.8838631', error '0.0000000'

Test #27:

score: 0
Accepted
time: 194ms
memory: 34176kb

input:

900 1000 1000
2856 9235
6656 -6886
-1550 9193
-7879 790
-2300 -1073
-3012 -6703
4982 -3176
4478 -3025
-778 -1807
-9273 -6952
-7759 6893
-1514 -3942
9614 -5497
1955 -2489
-4839 -4567
-8770 8394
2154 8743
-4737 6710
1247 9554
-992 -4388
-4955 5066
-2043 -6812
9759 1043
-4065 -2253
4453 -9621
-5136 -51...

output:

987999.2787579881

result:

ok found '987999.2787580', expected '987999.2787580', error '0.0000000'

Test #28:

score: 0
Accepted
time: 220ms
memory: 35248kb

input:

1000 1000 1000
1810 9255
-37 1995
2010 5545
7326 6698
-6420 -308
-2748 -7591
5956 -1415
-9799 -944
-1298 -4739
803 4033
-411 9850
-4961 609
-9571 -3416
2505 -5710
6401 2622
-254 -6368
-7371 -5975
7317 -5214
-2203 1887
7635 -9682
-1663 90
-5665 -8215
-7459 -4196
6608 -4677
8802 -3879
4305 4006
4323 -...

output:

1825100.3802688500

result:

ok found '1825100.3802688', expected '1825100.3802689', error '0.0000000'

Test #29:

score: 0
Accepted
time: 216ms
memory: 35280kb

input:

1000 1000 1000
-6902 -3387
2189 -4785
2673 -6027
8785 -9963
-626 -4522
1659 -2371
-7257 -6932
-9375 4135
9988 -2547
-5581 -4344
-555 4923
-4608 -4641
5912 -8176
6497 7117
-5931 -8260
-9677 -8546
-3542 -3892
-6043 -1941
9901 -1589
-9514 -8317
4047 3117
728 -6010
-6818 6729
-4233 -106
3918 4455
-6945 ...

output:

1671206.0961421929

result:

ok found '1671206.0961422', expected '1671206.0961422', error '0.0000000'