QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#248724#7184. Transport PlusesEWDEHSAMSWATERMELON#WA 0ms3972kbC++202.3kb2023-11-11 21:06:592023-11-11 21:07:00

Judging History

This is the latest submission verdict.

  • [2023-11-11 21:07:00]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3972kb
  • [2023-11-11 21:06:59]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;
#define int long long
using pii = pair <int, int>;
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template <typename T1, typename T2>
void mxr(T1& a, const T2& b) {
    if (b > a) {
        a = b;
    }
}

template <typename T1, typename T2>
void mnr(T1& a, const T2& b) {
    if (b < a) {
        a = b;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
#ifdef BUY
    freopen("inputik.txt", "r", stdin);
    freopen("outputik.txt", "w", stdout);
#else
    cin.tie(nullptr);
#endif

    int n, t; cin >> n >> t;
    int x1, y1; cin >> x1 >> y1;
    int x2, y2; cin >> x2 >> y2;
    vector <pair <int, int>> v(n);
    for (auto& [x, y] : v) {
        cin >> x >> y;
    }

    vector <int> d1(n), d2(n);
    vector <pair <int, int>> p1(n), p2(n);
    for (int i = 0; i < n; ++i) {
        if (abs(x1 - v[i].first) < abs(y1 - v[i].second)) {
            p1[i] = {v[i].first, y1};
        }
        else {
            p1[i] = {x1, v[i].second};
        }
        d1[i] = min(abs(x1 - v[i].first), abs(y1 - v[i].second));

        if (abs(x2 - v[i].first) < abs(y2 - v[i].second)) {
            p2[i] = {v[i].first, y2};
        }
        else {
            p2[i] = {x2, v[i].second};
        }
        d2[i] = min(abs(x2 - v[i].first), abs(y2 - v[i].second));
    }


    vector <tuple <int, int, int>> vans = {{0, x2, y2}};
    double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    for (int i = 0; i < n; ++i) {
        double cd = d1[i] + d2[i] + t;
        if (cd < ans) {
            ans = cd;
            vans = {{0, p1[i].first, p1[i].second}, {1, p2[i].first, p2[i].second}, {0, x2, y2}};
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int xp = v[i].first, yp = v[j].second;
            double cd = d1[i] + t + t + d2[j];
            if (cd < ans) {
                ans = cd;
                vans = {{0, p1[i].first, p1[i].second}, {1, xp, yp}, {1, p2[j].first, p2[j].second}, {0, x2, y2}};
            }
        }
    }

    cout << ans << '\n';
    cout << vans.size() << '\n';
    for (auto [a, b, c] : vans) {
        cout << a << ' ' << b << ' ' << c << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3972kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2
4
0 1 1
1 1 3
1 6 1
0 6 1

result:

wrong answer step 3: target (6.000000, 1.000000) not on plus (1.000000, 3.000000)