QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236469 | #7184. Transport Pluses | viniciuslettieri# | WA | 0ms | 4016kb | C++20 | 2.1kb | 2023-11-03 23:52:37 | 2023-11-03 23:52:38 |
Judging History
answer
#include<bits/stdc++.h>
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int N, T; cin >> N >> T;
int x0, x1, y0, y1; cin >> x0 >> y0 >> x1 >> y1;
vector<int> X(N), Y(N);
for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
double ans = sqrt(1.0 * (x0-x1) * (x0-x1) + (y0-y1) * (y0-y1));
vector<array<int, 3>> path = {{0, x1, y1}};
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (i != j) {
int dist = 2 * T + min(abs(x0-X[i]), abs(y0-Y[i])) + min(abs(x1-X[j]), abs(y1-Y[j]));
if (dist < ans) {
ans = dist;
vector<array<int, 3>> cur_path;
if (abs(x0 - X[i]) < abs(y0 - Y[i])) cur_path.push_back({0, X[i], y0});
else cur_path.push_back({0, x0, Y[i]});
cur_path.push_back({i+1, X[i], Y[j]});
if (abs(x1 - X[j]) < abs(y1 - Y[j])) cur_path.push_back({j+1, X[j], y1});
else cur_path.push_back({j+1, x1, Y[j]});
cur_path.push_back({0, x1, y1});
path = cur_path;
}
} else {
int dist = T + min(abs(x0-Y[i]), abs(y0-Y[i]))+ min(abs(x1-X[i]), abs(y1-Y[i]));
if (dist < ans) {
ans = dist;
vector<array<int, 3>> cur_path;
if (abs(x0 - X[i]) < abs(y0 - Y[i])) cur_path.push_back({0, X[i], y0});
else cur_path.push_back({0, x0, Y[i]});
if (abs(x1 - X[i]) < abs(y1 - Y[i])) cur_path.push_back({i+1, X[i], y1});
else cur_path.push_back({i+1, x1, Y[i]});
cur_path.push_back({0, x1, y1});
path = cur_path;
}
}
}
}
cout << fixed << setprecision(8) << ans << '\n';
cout << int(path.size()) << '\n';
for (const auto [x, y, z] : path) {
cout << x << ' ' << y << ' ' << z << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3996kb
input:
1 2 1 1 5 3 6 2
output:
4.00000000 3 0 1 2 1 5 2 0 5 3
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.00000000 4 0 1 1 1 1 3 2 6 1 0 6 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
0 0 1 1 1 1
output:
0.00000000 1 0 1 1
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
0 0 100 100 0 0
output:
141.42135624 1 0 0 0
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
1 0 100 100 0 0 100 100
output:
100.00000000 3 0 100 100 1 0 100 0 0 0
result:
ok correct
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 4016kb
input:
1 0 100 100 0 0 100 0
output:
100.00000000 3 0 100 100 1 0 0 0 0 0
result:
wrong answer claimed 100.0000000000, actual 0.0000000000