QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#308369#7184. Transport PlusesMladenPWA 0ms4044kbC++142.4kb2024-01-20 00:39:212024-01-20 00:39:22

Judging History

你现在查看的是最新测评结果

  • [2024-01-20 00:39:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4044kb
  • [2024-01-20 00:39:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
const int MAXN = 110;
const double INF = 1000000000;

double x[MAXN], y[MAXN];
double X1, X2, Y1, Y2;

double distPtoTP(double X, double Y, int idx) {
    return min(abs(X-x[idx]), abs(Y-y[idx]));
}

pair<double, double> pointPtoTP(double X, double Y, int idx) {
    if (abs(X-x[idx]) < abs(Y-y[idx])) {
        return {x[idx], Y};
    }
    return {X, y[idx]};
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int N, t; cin >> N >> t;
    cin >> X1 >> Y1;
    cin >> X2 >> Y2;

    for (int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i];
    }

    vector<pair<int, pair<int, int> > > r_sol;
    double sol = INF;

    /// 0 TPs
    sol = sqrt((X1-X2)*(X1-X2) + (Y1-Y2)*(Y1-Y2));
    r_sol.push_back({0, {X2, Y2}});

    /// 1 TP
    for (int i = 1; i <= N; i++) {
        if (distPtoTP(X1, Y1, i) + t + distPtoTP(X2, Y2, i) < sol) {
            r_sol.clear();
            sol = distPtoTP(X1, Y1, i) + t + distPtoTP(X2, Y2, i);

            if (distPtoTP(X1, Y1, i) != 0) {
                r_sol.push_back({0, pointPtoTP(X1, Y1, i)});
            }
            if (pointPtoTP(X1, Y1, i) != pointPtoTP(X2, Y2, i)) {
                r_sol.push_back({i, pointPtoTP(X2, Y2, i)});
            }
            if (distPtoTP(X1, Y1, i) != 0) {
                r_sol.push_back({0, {X2, Y2}});
            }
        }
    }
    /// 2 TPs
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (distPtoTP(X1, Y1, i) + 2*t + distPtoTP(X2, Y2, j) < sol) {
                r_sol.clear();
                sol = distPtoTP(X1, Y1, i) + 2*t + distPtoTP(X2, Y2, j);

                if (distPtoTP(X1, Y1, i) != 0) {
                    r_sol.push_back({0, pointPtoTP(X1, Y1, i)});
                }
                if (make_pair(x[i], y[j]) != pointPtoTP(X1, Y1, i)) {
                    r_sol.push_back({i, {x[i], y[j]}});
                }
                if (pointPtoTP(X1, Y1, i) != pointPtoTP(X2, Y2, j)) {
                    r_sol.push_back({j, pointPtoTP(X2, Y2, j)});
                }
                if (distPtoTP(X1, Y1, j) != 0) {
                    r_sol.push_back({0, {X2, Y2}});
                }
            }
        }
    }

    cout << sol << '\n' << r_sol.size() << '\n';
    for (auto x : r_sol) {
        cout << x.first << ' ' << x.second.first << ' ' << x.second.second << '\n';
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3940kb

input:

1 2
1 1
5 3
6 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2
3
1 1 3
2 6 1
0 6 1

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

0 0
1 1
1 1

output:

0
1
0 1 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

0 0
100 100
0 0

output:

141.421
1
0 0 0

result:

ok correct

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3760kb

input:

1 0
100 100
0 0
100 100

output:

100
1
1 0 100

result:

wrong answer arrived at (0.000000, 100.000000) instead of (0.000000, 0.000000)