QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425176 | #7184. Transport Pluses | real_sigma_team# | WA | 469ms | 4228kb | C++20 | 2.0kb | 2024-05-29 23:34:52 | 2024-05-29 23:34:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int A = 101;
int freex[A], freey[A], freexy[A][A], used[A][A];
double dist[A][A];
tuple<int, int, int> par[A][A];
void relax(int x, int y, int i, int j, int type, double add) {
if (dist[i][j] > dist[x][y] + add) {
par[i][j] = {type, x, y};
dist[i][j] = dist[x][y] + add;
}
}
int sqr(int x) {
return x * x;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, t;
cin >> n >> t;
int xh, yh, xe, ye;
cin >> xh >> yh >> xe >> ye;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
freex[x] = i;
freey[y] = i;
freexy[x][y] = i;
}
for (int i = 0; i < A; ++i) {
for (int j = 0; j < A; ++j) {
dist[i][j] = 1e9;
}
}
dist[xh][yh] = 0;
for (int iter = 0; iter < A * A; ++iter) {
int x = -1, y = -1;
for (int i = 0; i < A; ++i) {
for (int j = 0; j < A; ++j) {
if (dist[i][j] == 1e9 || used[i][j]) continue;
if (x == -1 || dist[i][j] < dist[x][y]) x = i, y = j;
}
}
for (int i = 0; i < A; ++i) {
for (int j = 0; j < A; ++j) {
if (i == x && freex[i]) relax(x, y, i, j, freex[i], t);
if (j == y && freey[j]) relax(x, y, i, j, freey[j], t);
if (freexy[i][y]) relax(x, y, i, j, freexy[i][y], t);
if (freexy[x][j]) relax(x, y, i, j, freexy[x][j], t);
relax(x, y, i, j, 0, sqrt(sqr(i - x) + sqr(j - y)));
}
}
used[x][y] = true;
}
cout << dist[xe][ye] << endl;
vector<tuple<int, int, int>> res;
while (make_pair(xe, ye) != make_pair(xh, yh)) {
res.push_back(par[xe][ye]);
auto [a, b, c] = par[xe][ye];
xe = b, ye = c;
}
reverse(res.begin(), res.end());
cout << res.size() << '\n';
for (auto [x, y, z] : res) cout << x << ' ' << y << ' ' << z << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 469ms
memory: 4228kb
input:
1 2 1 1 5 3 6 2
output:
4 3 0 1 1 1 1 2 0 5 2
result:
wrong answer step 2: source (1.000000, 1.000000) not on plus (6.000000, 2.000000)