QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#675420#7184. Transport PlusesaYi_7Compile Error//C++173.2kb2024-10-25 18:33:032024-10-25 18:33:03

Judging History

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

  • [2024-10-25 18:33:03]
  • 评测
  • [2024-10-25 18:33:03]
  • 提交

answer

#include <bits/stdc++.h>
// #define pii pair<int, int>
#define int long long
// using namespace std;
struct node {
    double dis;
    int x, y;
    int prex, prey;
    // bool tag;  // 是否在线上

    bool operator>(const node& a) const { return dis > a.dis; }
};

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

    std::map<std::pair<int, int>, std::set<std::pair<int, int>>> eg;
    std::map<std::pair<int, int>, std::pair<int, int>> rood;
    std::map<std::pair<int, int>, double> dis;
    std::set<int> x, y;
    std::priority_queue<node, std::vector<node>, std::greater<node>> q;

    for (int i = 0; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        x.insert(a);
        y.insert(b);
        for (int j = 0; j <= 100; j++) {
            for (int k = 0; k <= 100; k++) {
                eg[{a, j}].emplace(k, b);
                eg[{a, j}].emplace(a, k);
            }
        }
        for (int j = 0; j <= 100; j++) {
            for (int k = 0; k <= 100; k++) {
                eg[{j, b}].emplace(k, b);
                eg[{j, b}].emplace(a, k);
            }
        }
        q.emplace(std::abs(a - xh), a, yh, xh, yh);
        q.emplace(std::abs(b - yh), xh, b, xh, yh);
    }

    while (!q.empty()) {
        auto now = q.top();
        q.pop();
        int di = now.dis;
        std::pair<int, int> cur = std::make_pair(now.x, now.y);
        if (dis.count(cur)) continue;
        dis[cur] = di;
        rood[cur] = std::make_pair(now.prex, now.prey);
        for (auto& cur1 : eg[cur]) {
            if (dis.count(cur1)) continue;
            q.emplace(di + t, cur1.first, cur1.second, cur.first, cur.second);
        }
    }

    double ans = std::sqrt((double)(xh - xe) * (double)(xh - xe) +
                           (double)(yh - ye) * (double)(yh - ye));
    double len = 1e8;

    for (auto& [cur, di] : dis) {
        auto& [cx, cy] = cur;
        if (cx != xe || cy != ye) continue;
        double cost = std::max(std::fabs(cx - xe), std::fabs(cy - ye)) + di;
        if (cost < len) {
            len = cost;
            if (cx != xe || cy != ye) rood[{xe, ye}] = cur;
        }
    }

    auto check = [&](int X, int Y) -> bool {
        return x.count(X) || y.count(Y);
    };

    if (ans < len) {
        // std::cout << ans << '\n';
        printf("%.10f\n", ans);
        std::cout << 1 << '\n';
        std::cout << 0 << ' ' << xe << ' ' << ye << '\n';
    } else {
        // std::cout << len << '\n';
        printf("%.10f\n", len);
        std::vector<std::pair<int, int>> ans_rood;
        std::pair<int, int> cur = {xe, ye};
        while (cur.first != xh || cur.second != yh) {
            ans_rood.emplace_back(cur);
            cur = rood[cur];
        }
        std::reverse(ans_rood.begin(), ans_rood.end());
        std::cout << ans_rood.size() << '\n';
        for(int i = 0; i < n; i++) {
            
        }
    }
}

signed main() {
    // std::ios::sync_with_stdio(false);
    // std::cin.tie(nullptr);

    int t = 1;
    // std::cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}

详细

In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/c++allocator.h:33,
                 from /usr/include/c++/13/bits/allocator.h:46,
                 from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:1:
/usr/include/c++/13/bits/new_allocator.h: In instantiation of ‘void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = node; _Args = {long long int, long long int&, long long int&, long long int&, long long int&}; _Tp = node]’:
/usr/include/c++/13/bits/alloc_traits.h:537:17:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = node; _Args = {long long int, long long int&, long long int&, long long int&, long long int&}; _Tp = node; allocator_type = std::allocator<node>]’
/usr/include/c++/13/bits/vector.tcc:117:30:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int, long long int&, long long int&, long long int&, long long int&}; _Tp = node; _Alloc = std::allocator<node>; reference = node&]’
/usr/include/c++/13/bits/stl_queue.h:756:18:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {long long int, long long int&, long long int&, long long int&, long long int&}; _Tp = node; _Sequence = std::vector<node>; _Compare = std::greater<node>]’
answer.code:43:18:   required from here
/usr/include/c++/13/bits/new_allocator.h:187:11: error: new initializer expression list treated as compound expression [-fpermissive]
  187 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/new_allocator.h:187:11: error: no matching function for call to ‘node::node(long long int&)’
answer.code:5:8: note: candidate: ‘node::node()’
    5 | struct node {
      |        ^~~~
answer.code:5:8: note:   candidate expects 0 arguments, 1 provided
answer.code:5:8: note: candidate: ‘constexpr node::node(const node&)’
answer.code:5:8: note:   no known conversion for argument 1 from ‘long long int’ to ‘const node&’
answer.code:5:8: note: candidate: ‘constexpr node::node(node&&)’
answer.code:5:8: note:   no known conversion for argument 1 from ‘long long int’ to ‘node&&’
/usr/include/c++/13/bits/new_allocator.h: In instantiation of ‘void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = node; _Args = {long long int, const long long int&, const long long int&, long long int&, long long int&}; _Tp = node]’:
/usr/include/c++/13/bits/alloc_traits.h:537:17:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = node; _Args = {long long int, const long long int&, const long long int&, long long int&, long long int&}; _Tp = node; allocator_type = std::allocator<node>]’
/usr/include/c++/13/bits/vector.tcc:117:30:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int, const long long int&, const long long int&, long long int&, long long int&}; _Tp = node; _Alloc = std::allocator<node>; reference = node&]’
/usr/include/c++/13/bits/stl_queue.h:756:18:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {long long int, const long long int&, const long long int&, long long int&, long long int&}; _Tp = node; _Sequence = std::vector<node>; _Compare = std::greater<node>]’
answer.code:57:22:   required from here
/usr/include/c++/13/bits/new_allocator.h:187:11: error: new initializer expression list treated as compound expression [-fpermissive]
  187 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/new_allocator.h:187:11: error: no matching function for call to ‘node::node(long long int&)’
answer.code:5:8: note: candidate: ‘node::node()’
    5 | struct node {
      |        ^~~~
answer.code:5:8: note:   candidate expects 0 arguments, 1 provided
answer.code:5:8: note: candidate: ‘constexpr node::node(const node&)’
answer.code:5:8: note:   no known conversion for argument 1 from ‘long long int’ to ‘const node&’
answer.code:5:8: note: candidate: ‘constexpr node::node(node&&)’
answer.code:5:8: note:   no known conversion for argument 1 from ‘long long int’ to ‘node&&’