QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#406809#6659. 외곽 순환 도로 2PanndaCompile Error//C++204.1kb2024-05-07 18:55:252024-05-07 18:55:27

Judging History

你现在查看的是测评时间为 2024-05-07 18:55:27 的历史记录

  • [2024-08-26 15:52:33]
  • 管理员手动重测本题所有提交记录
  • [2024-05-07 18:55:27]
  • 评测
  • [2024-05-07 18:55:25]
  • 提交

answer

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

const long long INF = 1e18;

long long place_police(vector<int> par, vector<long long> wpar, vector<long long> weights) {
    par.insert(par.begin(), -1);
    wpar.insert(wpar.begin(), -1);
    int n = par.size();
    int k = weights.size();

    vector<vector<int>> adj(n);
    for (int u = 1; u < n; u++) {
        adj[par[u]].push_back(u);
    }

    int cnt = 0;
    auto dfs = [&](auto self, int u) -> vector<vector<vector<vector<long long>>>> {
        if (adj[u].empty()) {
            vector<vector<vector<vector<long long>>>> res(2, vector<vector<vector<long long>>>(2, vector<vector<long long>>(3, vector<long long>(3, INF))));
            cnt++;
            res[0][0][0][0] = 0;
            res[1][0][1][1] = 0;
            return res;
        }

        vector<vector<vector<vector<long long>>>> res(2, vector<vector<vector<long long>>>(2, vector<vector<long long>>(3, vector<long long>(3, INF))));
        for (int c = 0; c < 2; c++) {
            for (int l = 0; l < 2; l++) {
                for (int r = 0; r < 2; r++) {
                    res[c][0][l][r] = 0;
                }
            }
        }
        bool first = true;
        for (int v : adj[u]) {
            auto get = self(self, v);
            long long cost = weights[cnt - 1];
            vector<vector<vector<vector<long long>>>> upd(2, vector<vector<vector<long long>>>(2, vector<vector<long long>>(3, vector<long long>(3, INF))));
            for (int cu = 0; cu < 2; cu++) for (int tu = 0; tu < 2; tu++) {
                for (int lu = 0; lu < 3; lu++) {
                    for (int ru = 0; ru < 3; ru++) {
                        for (int cv = 0; cv < 2; cv++) for (int tv = 0; tv < 2; tv++) {
                            for (int lv = 0; lv < 3; lv++) {
                                for (int rv = 0; rv < 3; rv++) {
                                    upd[cu][tu | tv][first ? 2 : lu][2] = min(upd[cu][tu | tv][first ? 2 : lu][2], res[cu][tu][lu][ru] + get[cv][tv][lv][rv] + wpar[v]);
                                    if (cu != cv) {
                                        int t = ru <= 1 && lv <= 1 && ru == lv;
                                        upd[cu][tu | tv | t][lu][rv] = min(upd[cu][tu | tv | t][lu][rv], res[cu][tu][lu][ru] + get[cv][tv][lv][rv] + cost * t);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            res = upd;
            first = false;
        }

        return res;
    };
    auto res = dfs(dfs, 0);

    long long ans = INF;

    if (k & 1) {
        for (int c = 0; c < 2; c++) {
            for (int l = 0; l < 3; l++) {
                for (int r = 0; r < 3; r++) {
                    if (l == 2 || r == 2 || l != r) {
                        ans = min(ans, res[c][1][l][r]);
                    } else {
                        ans = min(ans, res[c][0][l][r] + weights.back());
                        ans = min(ans, res[c][1][l][r] + weights.back());
                    }
                }
            }
        }
    } else {
        for (int c = 0; c < 2; c++) for (int t = 0; t < 2; t++) {
            for (int l = 0; l < 3; l++) {
                for (int r = 0; r < 3; r++) {
                    ans = min(ans, res[c][t]z[l][r]);
                }
            }
        }
    }

    return ans;
}

//template<class T>
//void read(vector<T> &a) {
//    if (a.empty()) {
//        T x;
//        while (cin >> x) {
//            if (x == -1) break;
//            a.push_back(x);
//        }
//    } else {
//        for (T &x : a) {
//            cin >> x;
//        }
//    }
//}
//int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr);
//    int n;
//    cin >> n;
//    vector<int> par(n - 1);
//    vector<long long> wpar(n - 1);
//    vector<long long> weights;
//    for (int i = 0; i < n - 1; i++) {
//        cin >> par[i] >> wpar[i];
//    }
//    read<long long>(weights);
//    cout << place_police(par, wpar, weights);
//}

详细

answer.code: In function ‘long long int place_police(std::vector<int>, std::vector<long long int>, std::vector<long long int>)’:
answer.code:84:45: error: expected ‘)’ before ‘z’
   84 |                     ans = min(ans, res[c][t]z[l][r]);
      |                              ~              ^
      |                                             )
answer.code:84:30: error: no matching function for call to ‘min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<std::vector<std::vector<long long int> > >, std::vector<std::vector<long long int> > >::value_type&)’
   84 |                     ans = min(ans, res[c][t]z[l][r]);
      |                           ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:84:30: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::vector<long long int> > >, std::vector<std::vector<long long int> > >::value_type’ {aka ‘std::vector<std::vector<long long int> >’})
   84 |                     ans = min(ans, res[c][t]z[l][r]);
      |                           ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:84:30: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::vector<long long int> > >, std::vector<std::vector<long long int> > >::value_type’ {aka ‘std::vector<std::vector<long long int> >’})
   84 |                     ans = min(ans, res[c][t]z[l][r]);
      |                           ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:84:30: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   84 |                     ans = min(ans, res[c][t]z[l][r]);
      |                           ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:84:30: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   84 |                     ans = min(ans, res[c][t]z[l][r]);
      |                           ~~~^~~~~~~~~~~~~~~~