QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#170333 | #7184. Transport Pluses | ucup-team1264# | WA | 201ms | 4368kb | C++20 | 2.4kb | 2023-09-09 15:02:10 | 2023-09-09 15:02:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
double eps = 1e-7;
void solve() {
int n, t;
cin >> n >> t;
int xs, ys, xt, yt;
cin >> xs >> ys >> xt >> yt;
vector<vector<int>> pnt(101, vector<int>(101, 0));
vector<vector<double>> ans(101, vector<double>(101, 1e5));
vector<vector<int>> chosen(101, vector<int>(101, 0));
for (int i = 1; i <= n; i++) {
int x, y;
cin >> x >> y;
pnt[x][y] = i;
}
vector fa(101, vector<tuple<int, int, int>>(101, {-1, -1, -1}));
ans[xs][ys] = 0;
for (int _ = 0; _ < 101 * 101; _++) {
int mn = 1e5;
pair<int, int> mnp = {-1, -1};
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
if (!chosen[i][j] && ans[i][j] < mn) {
mn = ans[i][j];
mnp = {i, j};
}
}
}
auto [x, y] = mnp;
if (x == xt && y == yt) break;
chosen[x][y] = 1;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
if (chosen[i][j]) continue;
if (ans[x][y] + sqrt((i - x) * (i - x) + (j - y) * (j - y)) <
ans[i][j] - eps) {
ans[i][j] =
ans[x][y] + sqrt((i - x) * (i - x) + (j - y) * (j - y));
fa[i][j] = {0, x, y};
}
if (ans[x][y] + t < ans[i][j] - eps) {
if (pnt[i][y]) {
ans[i][j] = ans[x][y] + t;
fa[i][j] = {pnt[i][y], x, y};
} else if (pnt[x][j]) {
ans[i][j] = ans[x][y] + t;
fa[i][j] = {pnt[x][j], x, y};
}
}
}
}
}
cout << fixed << setprecision(10) << ans[xt][yt] << "\n";
vector<tuple<int, int, int>> res;
for (int i = xt, j = yt; i != xs || j != ys;) {
auto [tp, x, y] = fa[i][j];
res.emplace_back(tp, i, j);
i = x, j = y;
}
ranges::reverse(res);
cout << res.size() << "\n";
for (auto [tp, x, y] : res) {
cout << tp << " " << x << " " << y << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 4356kb
input:
1 2 1 1 5 3 6 2
output:
4.0000000000 3 0 1 2 1 6 3 0 5 3
result:
ok correct
Test #2:
score: 0
Accepted
time: 8ms
memory: 4116kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.0000000000 2 1 0 3 2 6 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 4084kb
input:
0 0 1 1 1 1
output:
0.0000000000 0
result:
ok correct
Test #4:
score: 0
Accepted
time: 201ms
memory: 4120kb
input:
0 0 100 100 0 0
output:
141.4213562373 1 0 0 0
result:
ok correct
Test #5:
score: 0
Accepted
time: 193ms
memory: 4340kb
input:
1 0 100 100 0 0 100 100
output:
100.0000000000 2 1 0 100 0 0 0
result:
ok correct
Test #6:
score: 0
Accepted
time: 1ms
memory: 4368kb
input:
1 0 100 100 0 0 100 0
output:
0.0000000000 1 1 0 0
result:
ok correct
Test #7:
score: 0
Accepted
time: 1ms
memory: 4276kb
input:
1 0 100 100 0 0 0 100
output:
0.0000000000 1 1 0 0
result:
ok correct
Test #8:
score: 0
Accepted
time: 175ms
memory: 4120kb
input:
1 100 50 50 0 0 50 50
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #9:
score: 0
Accepted
time: 173ms
memory: 4124kb
input:
1 100 50 50 0 0 0 50
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #10:
score: 0
Accepted
time: 172ms
memory: 4244kb
input:
1 100 50 50 0 0 51 51
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #11:
score: 0
Accepted
time: 172ms
memory: 4216kb
input:
1 100 50 50 0 0 2 53
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #12:
score: 0
Accepted
time: 172ms
memory: 4112kb
input:
1 100 0 0 100 100 50 50
output:
141.4213562373 1 0 100 100
result:
ok correct
Test #13:
score: 0
Accepted
time: 186ms
memory: 4124kb
input:
1 33 0 0 100 100 50 50
output:
133.0000000000 3 0 0 50 1 50 100 0 100 100
result:
ok correct
Test #14:
score: 0
Accepted
time: 196ms
memory: 4184kb
input:
1 12 100 0 11 90 0 100
output:
122.0000000000 3 0 0 0 1 11 100 0 11 90
result:
ok correct
Test #15:
score: 0
Accepted
time: 195ms
memory: 4116kb
input:
1 12 100 0 10 89 0 100
output:
122.0000000000 3 0 100 100 1 0 89 0 10 89
result:
ok correct
Test #16:
score: 0
Accepted
time: 8ms
memory: 4344kb
input:
2 1 2 1 5 1 1 3 6 3
output:
3.0000000000 1 0 5 1
result:
ok correct
Test #17:
score: 0
Accepted
time: 1ms
memory: 4348kb
input:
2 2 2 1 5 1 1 3 6 3
output:
3.0000000000 1 0 5 1
result:
ok correct
Test #18:
score: -100
Wrong Answer
time: 6ms
memory: 4216kb
input:
1 2 1 1 5 3 7 2
output:
4.4721359550 1 0 5 3
result:
wrong answer read 4.472136 but expected 4.000000, error = 0.472136