QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#170077 | #7184. Transport Pluses | ucup-team1264# | WA | 183ms | 4344kb | C++20 | 2.4kb | 2023-09-09 14:34:13 | 2023-09-09 14:43:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int N = 101 * 101;
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; _ < N; _++) {
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]) {
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]) {
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: 5ms
memory: 4144kb
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: 4176kb
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: 0ms
memory: 4144kb
input:
0 0 1 1 1 1
output:
0.0000000000 0
result:
ok correct
Test #4:
score: 0
Accepted
time: 183ms
memory: 4120kb
input:
0 0 100 100 0 0
output:
141.4213562373 53 0 99 99 0 96 96 0 93 93 0 90 90 0 87 87 0 84 84 0 81 81 0 76 76 0 75 75 0 74 74 0 73 73 0 72 72 0 71 71 0 70 70 0 69 69 0 68 68 0 67 67 0 66 66 0 65 65 0 64 64 0 63 63 0 62 62 0 61 61 0 60 60 0 59 59 0 58 58 0 57 57 0 56 56 0 55 55 0 53 53 0 51 51 0 49 49 0 47 47 0 45 45 0 43 43 0 ...
result:
ok correct
Test #5:
score: 0
Accepted
time: 179ms
memory: 4172kb
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: 4248kb
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: 4340kb
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: 164ms
memory: 4340kb
input:
1 100 50 50 0 0 50 50
output:
70.7106781187 31 0 49 49 0 46 46 0 43 43 0 40 40 0 37 37 0 34 34 0 31 31 0 26 26 0 25 25 0 24 24 0 23 23 0 22 22 0 21 21 0 20 20 0 19 19 0 18 18 0 17 17 0 16 16 0 15 15 0 14 14 0 13 13 0 12 12 0 11 11 0 10 10 0 9 9 0 8 8 0 7 7 0 6 6 0 4 4 0 2 2 0 0 0
result:
ok correct
Test #9:
score: 0
Accepted
time: 160ms
memory: 4128kb
input:
1 100 50 50 0 0 0 50
output:
70.7106781187 31 0 49 49 0 46 46 0 43 43 0 40 40 0 37 37 0 34 34 0 31 31 0 26 26 0 25 25 0 24 24 0 23 23 0 22 22 0 21 21 0 20 20 0 19 19 0 18 18 0 17 17 0 16 16 0 15 15 0 14 14 0 13 13 0 12 12 0 11 11 0 10 10 0 9 9 0 8 8 0 7 7 0 6 6 0 4 4 0 2 2 0 0 0
result:
ok correct
Test #10:
score: 0
Accepted
time: 163ms
memory: 4112kb
input:
1 100 50 50 0 0 51 51
output:
70.7106781187 31 0 49 49 0 46 46 0 43 43 0 40 40 0 37 37 0 34 34 0 31 31 0 26 26 0 25 25 0 24 24 0 23 23 0 22 22 0 21 21 0 20 20 0 19 19 0 18 18 0 17 17 0 16 16 0 15 15 0 14 14 0 13 13 0 12 12 0 11 11 0 10 10 0 9 9 0 8 8 0 7 7 0 6 6 0 4 4 0 2 2 0 0 0
result:
ok correct
Test #11:
score: 0
Accepted
time: 164ms
memory: 4116kb
input:
1 100 50 50 0 0 2 53
output:
70.7106781187 31 0 49 49 0 46 46 0 43 43 0 40 40 0 37 37 0 34 34 0 31 31 0 26 26 0 25 25 0 24 24 0 23 23 0 22 22 0 21 21 0 20 20 0 19 19 0 18 18 0 17 17 0 16 16 0 15 15 0 14 14 0 13 13 0 12 12 0 11 11 0 10 10 0 9 9 0 8 8 0 7 7 0 6 6 0 4 4 0 2 2 0 0 0
result:
ok correct
Test #12:
score: 0
Accepted
time: 165ms
memory: 4116kb
input:
1 100 0 0 100 100 50 50
output:
141.4213562373 53 0 1 1 0 4 4 0 7 7 0 10 10 0 13 13 0 16 16 0 19 19 0 24 24 0 25 25 0 26 26 0 27 27 0 28 28 0 29 29 0 30 30 0 31 31 0 32 32 0 33 33 0 34 34 0 35 35 0 36 36 0 37 37 0 38 38 0 39 39 0 40 40 0 41 41 0 42 42 0 43 43 0 44 44 0 45 45 0 47 47 0 49 49 0 51 51 0 53 53 0 55 55 0 57 57 0 59 59 ...
result:
ok correct
Test #13:
score: 0
Accepted
time: 174ms
memory: 4244kb
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: 178ms
memory: 4216kb
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: 183ms
memory: 4060kb
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: 2ms
memory: 4120kb
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: 3ms
memory: 4112kb
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