QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#380548#7184. Transport Plusesucup-team992#Compile Error//C++232.6kb2024-04-07 05:43:232024-04-07 05:43:23

Judging History

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

  • [2024-04-07 05:43:23]
  • 评测
  • [2024-04-07 05:43:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ar arry
typedef int uci;
#define int long long
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXN = 101;

double d[MAXN][MAXN];
array<int, 3> prv[MAXN][MAXN];

#define sq(a) (a)*(a)
double dist(int x1, int y1, int x2, int y2) {
    return sqrtl(sq(x1-x2) + sq(y1-y2));
}

struct node {
    double d;
    int x, y;
    int pt, px, py;

    operator > (node& o) {
        return d > o.d;
    }
};



void solve(){
    int n, t; cin >> n >> t;
    int xh, yh; cin >> xh >> yh;
    int xe, ye; cin >> xe >> ye;

    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }

    for (int i = 0; i < MAXN; i++) {
        for (int j = 0; j < MAXN; j++) {
            d[i][j] = 1e18;
        }
    }

    priority_queue<node, vector<node>, greater<>> pq;
    pq.push({0, xh, yh, -1, 0, 0});
    while (not empty(pq)) {
        node c = pq.top(); pq.pop();

        if (d[c.x][c.y] == 1e18) {
            d[c.x][c.y] = c.d;
            prv[c.x][c.y] = {c.pt, c.px, c.py};

            // Use seg
            for (auto [x, y]: p) {
                if (abs(c.x - x) < abs(c.y - y)) {
                    pq.push({c.d + abs(c.x-x), x, c.y, 0, c.x, c.y});
                }
                else {
                    pq.push({c.d + abs(c.y-y), c.x, y, 0, c.x, c.y});
                }
            }
            pq.push({c.d + dist(c.x, c.y, xe, ye), xe, ye, 0, c.x, c.y});

            // Don't use seg
            for (int i = 0; i < n; i++) {
                auto [x, y] = p[i];

                if (x == c.x or y == c.y) {
                    for (int y2 = 0; y2 <= 100; y2++) {
                        pq.push({c.d + t, x, y2, i+1, c.x, c.y});
                    }
                    for (int x2 = 0; x2 <= 100; x2++) {
                        pq.push({c.d + t, x2, y, i+1, c.x, c.y});
                    }
                }
            }
            
        }
    }



    vector<array<int, 3>> ans;
    int cx = xe, cy = ye;
    while (prv[cx][cy][0] != -1) {
        ans.push_back({prv[cx][cy][0], cx, cy});    

        int nx = prv[cx][cy][1];
        int ny = prv[cx][cy][2];
        cx = nx;
        cy = ny;
    }
    reverse(ans.begin(), ans.end());

    cout << d[xe][ye] << '\n';
    cout << size(ans) << '\n';
    for (auto e: ans) {
        cout << e[0] << ' ' << e[1] << ' ' << e[2] << '\n';
    }
    
}

uci main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    solve();
}

Details

answer.code:31:5: error: ISO C++ forbids declaration of ‘operator>’ with no type [-fpermissive]
   31 |     operator > (node& o) {
      |     ^~~~~~~~