QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575614 | #3195. Within Arm's Reach | caijianhong | WA | 0ms | 4416kb | C++23 | 1.6kb | 2024-09-19 15:51:58 | 2024-09-19 15:51:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define debug(...) fprintf(stderr, ##__VA_ARGS__)
#else
#define endl "\n"
#define debug(...) void(0)
#endif
using LL = long long;
using point = complex<double>;
int n;
pair<double, int> b[30];
point tar, ans[30];
int main() {
#ifndef LOCAL
cin.tie(nullptr)->sync_with_stdio(false);
#endif
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++) cin >> b[i].first, sum += b[i].first, b[i].second = i;
{/*{{{*/
double tx, ty;
cin >> tx >> ty;
tar = point{tx, ty};
}/*}}}*/
if (sum > abs(tar)) {
sort(b + 1, b + n + 1);
double pre = 0;
for (int i = 1; i <= n; i++) {
pre += b[i].first;
int id = b[i].second;
if (sum - pre * 2 - abs(tar) <= 1e-4) {
double a = b[i].first, b = pre - a + abs(tar), c = sum - pre;
if (a + b + c > 2 * max({a, b, c})) {
double angc = acos((a * a + b * b - c * c) / (2 * a * b));
point tmp = ans[id] = polar(a, angc);
point all = (b - tmp) / c;
for (int j = i + 1; j <= n; j++) ans[::b[j].second] = all * ::b[j].first;
} else {
ans[id] = -a;
for (int j = i + 1; j <= n; j++) ans[::b[j].second] = ::b[j].first;
}
break;
}
ans[b[i].second] = -b[i].first;
}
} else {
for (int i = 1; i <= n; i++) ans[b[i].second] = b[i].first;
}
point now = 0;
cout << fixed << setprecision(6);
for (int i = 1; i <= n; i++) {
now += ans[i] * polar(1., arg(tar));
cout << real(now) << " " << imag(now) << endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4416kb
input:
2 4 2 -8 -3
output:
-3.745317 -1.404494 -5.617975 -2.106741
result:
ok ACCEPTED
Test #2:
score: 0
Accepted
time: 0ms
memory: 4040kb
input:
1 10 10 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #3:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
1 10 0 0
output:
-10.000000 0.000000
result:
ok ACCEPTED
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 4344kb
input:
2 10 5 2 2
output:
-7.071068 -7.071068 -10.606602 -10.606602
result:
wrong answer WRONG ANSWER: segment exceeds EPSILON diff = 15.656855