QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#186544#7184. Transport Plusesucup-team1430#RE 1ms3720kbC++202.3kb2023-09-24 02:21:112023-09-24 02:21:11

Judging History

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

  • [2023-09-24 02:21:11]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3720kb
  • [2023-09-24 02:21:11]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define ld long double
#define pb push_back
#define sws cin.tie(0)->sync_with_stdio(false);
#define endl '\n'

using namespace std;

const int N = 1e5+10;
const ll MOD = 998244353;
// const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

struct point {
    int x, y;
};

ld dpoint(point p1, point p2) {
    ll dx = p1.x - p2.x, dy = p1.y - p2.y;
    return sqrt(dx * dx + dy * dy);
}

ld dtele(point p, point tele) {
    return min(abs(p.x - tele.x), abs(p.y - tele.y));
}

point closest(point p, point tele) {
    if (abs(p.x - tele.x) < abs(p.y - tele.y)) {
        return {tele.x, p.y};
    } else {
        return {p.x, tele.y};
    }
}
point inter(point tele1, point tele2) {
    return {tele1.x, tele2.y};
}

int32_t main()
{
    #ifndef LOCAL
    sws;
    #endif

    int n, t; cin >> n >> t;
    point p1, p2;
    cin >> p1.x >> p1.y; cin >> p2.x >> p2.y;
    vector<point> tele(n);
    for (int i=0;i<n;i++) {
        cin >> tele[i].x >> tele[i].y;
    }

    ld cost = dpoint(p1, p2);
    vector<pair<int, point>> path = {{0, p2}};
    
    for (int i=0;i<n;i++) {
        ld cost2 = dtele(p1, tele[i]) + t + dtele(p2, tele[i]);
        if (cost2 < cost) {
            cost = cost2;
            path.clear();
            path.push_back({0, closest(p1, tele[i])});
            path.push_back({i+1, closest(p2, tele[i])});
            path.push_back({0, p2});
        }
    }

    int d1 = 0, d2 = 0;
    for (int i=0;i<n;i++) {
        if (dtele(p1, tele[i]) < dtele(p1, tele[d1])) d1 = i;
        if (dtele(p2, tele[i]) < dtele(p2, tele[d2])) d2 = i;
    }
    ll cost3 = dtele(p1, tele[d1]) + 2*t + dtele(p2, tele[d2]);
    if (cost3 < cost) {
        cost = cost3;
        path.clear();
        path.push_back({0, closest(p1, tele[d1])});
        path.push_back({d1+1, inter(tele[d1], tele[d2])});
        path.push_back({d2+1, closest(p2, tele[d2])});
        path.push_back({0, p2});
    }

    cout << fixed << setprecision(9) << cost << endl;
    cout << path.size() << endl;
    for (auto [p, pi]: path) {
        cout << p << " " << pi.x << " " << pi.y << endl;
    }


    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3720kb

input:

1 2
1 1
5 3
6 2

output:

4.000000000
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

2 1
1 1
6 1
1 3
6 3

output:

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

result:

ok correct

Test #3:

score: -100
Runtime Error

input:

0 0
1 1
1 1

output:


result: