QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#171856 | #7184. Transport Pluses | ucup-team059# | WA | 1ms | 3892kb | C++20 | 2.1kb | 2023-09-09 17:41:50 | 2023-09-09 17:41:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
using ldb = long double;
using pdd = pair<ldb, ldb>;
ldb dis(pdd a, pdd b) {
return min(abs(a.first - b.first), abs(a.second - b.second));
}
ldb dist(pdd a, pdd b) {
return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
void calc(const vector<ldb> &d, const vector<pdd> &pluses, const pdd &x, const int &y, int t) {
if (t == 0) cout << "0 ";
else cout << y+1 << " ";
if (d[y] == abs(x.first - pluses[y].first))
cout << pluses[y].first << " " << x.second << "\n";
else
cout << x.first << " " << pluses[y].second << "\n";
return;
}
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0);
int n;
ldb t;
cin >> n >> t;
pdd a, b;
cin >> a.first >> a.second >> b.first >> b.second;
ldb res = dist(a, b);
vector<int> d;
vector<ldb> da, db;
vector<pdd> pluses(n);
for (auto &[x, y]: pluses)
cin >> x >> y;
for (auto i: pluses)
da.push_back(dis(a, i)), db.push_back(dis(b, i));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
ldb ans = da[i] + db[j];
if (i == j) ans += t;
else ans += 2 * t;
if (ans < res) {
res = ans;
d = vector<int>();
d.push_back(i);
if (i != j) d.push_back(j);
}
}
cout << fixed << setprecision(6) << res << "\n";
if (d.empty()) {
cout << "1\n0 " << b.first << b.second;
} else if (d.size() == 1) {
cout << "3\n";
calc(da, pluses, a, d.front(), 0);
calc(db, pluses, b, d.back(), 1);
cout << "0 " << b.first << " " << b.second << "\n";
} else {
cout << "4\n";
calc(da, pluses, a, d.front(), 0);
cout << d.front()+1 << " " << pluses[d.front()].first << " " << pluses[d.back()].second << "\n";
calc(db, pluses, b, d.back(), 1);
cout << "0 " << b.first << " " << b.second << "\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3828kb
input:
1 2 1 1 5 3 6 2
output:
4.000000 3 0 1.000000 2.000000 1 6.000000 3.000000 0 5.000000 3.000000
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.000000 4 0 1.000000 1.000000 1 1.000000 3.000000 2 6.000000 1.000000 0 6.000000 1.000000
result:
ok correct
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3836kb
input:
0 0 1 1 1 1
output:
0.000000 1 0 1.0000001.000000
result:
wrong output format Expected double, but "1.0000001.000000" found