QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#170057 | #7184. Transport Pluses | ucup-team918# | WA | 1ms | 3888kb | C++17 | 2.2kb | 2023-09-09 14:33:08 | 2023-09-09 14:38:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ld long double
int n, t, sx, sy, tx, ty, x[110], y[110];
ld dis(int xa, int ya, int xb, int yb) {
return sqrtl((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
}
signed main() {
cin >> n >> t >> sx >> sy >> tx >> ty;
for (int i = 1; i <= n; i++)
cin >> x[i] >> y[i];
ld ans = dis(sx, sy, tx, ty);
int flagx = 0, flagy = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
ld res = t * 2;
res += min(abs(sx - x[i]), abs(sy - y[i]));
res += min(abs(tx - x[j]), abs(ty - y[j]));
if (ans > res) ans = res, flagx = i, flagy = j;
res = t;
res += dis(sx, sy, x[i], y[j]);
res += dis(tx, ty, x[j], y[i]);
if (ans > res) ans = res, flagx = -i, flagy = -j;
if (i != j) continue;
res = t;
res += min(abs(sx - x[i]), abs(sy - y[i]));
res += min(abs(tx - x[j]), abs(ty - y[j]));
if (ans > res) ans = res, flagx = i, flagy = i;
}
cout << fixed << setprecision(6) << ans << endl;
if (flagx == 0) {
cout << 1 << endl;
cout << 0 << " " << tx << " " << ty << endl;
}
else if (flagx > 0) {
if (flagx != flagy) {
cout << 4 << endl;
int i = flagx, j = flagy;
if (abs(sx - x[i]) < abs(sy - y[i]))
cout << 0 << " " << x[i] << " " << sy << endl;
else cout << 0 << " " << sx << " " << y[i] << endl;
cout << 1 << " " << x[i] << " " << y[j] << endl;
if (abs(tx - x[j]) < abs(ty - y[j]))
cout << 1 << " " << x[j] << " " << ty << endl;
else cout << 1 << " " << tx << " " << y[j] << endl;
cout << 0 << " " << tx << " " << ty << endl;
}
else {
cout << 3 << endl;
int i = flagx, j = flagy;
if (abs(sx - x[i]) < abs(sy - y[i]))
cout << 0 << " " << x[i] << " " << sy << endl;
else cout << 0 << " " << sx << " " << y[i] << endl;
if (abs(tx - x[j]) < abs(ty - y[j]))
cout << 1 << " " << x[j] << " " << ty << endl;
else cout << 1 << " " << tx << " " << y[j] << endl;
cout << 0 << " " << tx << " " << ty << endl;
}
}
else {
cout << 3 << endl;
int i = -flagx, j = -flagy;
cout << 0 << " " << x[i] << " " << y[j] << endl;
cout << 1 << " " << x[j] << " " << y[i] << endl;
cout << 0 << " " << tx << " " << ty << endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3888kb
input:
1 2 1 1 5 3 6 2
output:
4.000000 3 0 1 2 1 5 2 0 5 3
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3832kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.000000 4 0 1 1 1 1 3 1 6 1 0 6 1
result:
wrong answer step 3: target (6.000000, 1.000000) not on plus (1.000000, 3.000000)