QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793956#8864. Ball PassingalexhamidiWA 0ms3804kbC++20991b2024-11-30 06:47:292024-11-30 06:47:31

Judging History

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

  • [2024-11-30 06:47:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-11-30 06:47:29]
  • 提交

answer

#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

double sq(double x) {
    return x * x;
}

double getDistance(pair<double, double> a, pair<double, double> b) {
    auto [xa, ya] = a;
    auto [xb, yb] = b;
    return sqrt(sq(xa-xb) + sq(ya-yb));
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<pair<int, int>> b;
    vector<pair<int, int>> g;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (s[i] == 'B') {
            b.push_back({x, y});
        } else {
            g.push_back({x, y});
        }
    }


    int bs = b.size();
    int gs = g.size();

    double ans;

    for (int i = 0; i < bs/2; i++) {
        int opp = i + bs/2;
        ans+=getDistance(b[i], b[opp]);
    }

    for (int i = 0; i < gs/2; i++) {
        int opp = i + gs/2;
        ans+=getDistance(g[i], g[opp]);
    }

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
BBGG
-1 -10
-10 -2
-8 7
7 -8

output:

33.2548

result:

ok found '33.2548000', expected '33.2547980', error '0.0000001'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3748kb

input:

10
GBGBBBGBBG
-30 2
-28 10
-5 30
6 29
15 26
22 20
29 9
27 -12
-14 -27
-22 -20

output:

269.695

result:

wrong answer 1st numbers differ - expected: '269.6953830', found: '269.6950000', error = '0.0000014'