QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#793956 | #8864. Ball Passing | alexhamidi | WA | 0ms | 3804kb | C++20 | 991b | 2024-11-30 06:47:29 | 2024-11-30 06:47:31 |
Judging History
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;
}
详细
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'