QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662451#6438. CrystalflykukkaCompile Error//C++201.9kb2024-10-21 00:40:062024-10-21 00:40:07

Judging History

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

  • [2024-10-21 00:40:07]
  • 评测
  • [2024-10-21 00:40:06]
  • 提交

answer

#define GCC optimille(3)
#include <bits/stdc++.h>
using namespace std;

using i64 = int64_t;
using i128 = __int128;

#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#ifdef DEBUG
    #define cout cout << "\033[1;92m"
    #define endl "\033[0m" << '\n';
#else
    #define endl '\n'
#endif

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n+1,0), t(n+1,0);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> t[i];

    vector<vector<i64>> edges(n+1);
    for (int i = 1; i <= n-1; ++i) {
        i64 from, to;
        cin >> from >> to;
        edges[from].push_back(to);
        edges[to].push_back(from);
    }

    vector<i64> dis(n+1,0), mx(n+1,0), sum(n+1,0);

    function<void(i64,i64)> dfs = [&](i64 cur, i64 fa) -> void {
        if (edges[cur].size() == 1ll && edges[cur][0] == fa) {
            dis[cur] = a[cur];
            return;
        }

        i64 fi{}, se{}, temp{};
        for (auto&& to : edges[cur]) {
            if (to == fa) continue;
            if (t[to] == 3ll && a[to] >= temp) {
                temp = a[to];
                se = fi;
                fi = to;
            }
            dfs(to, cur);
            sum[cur] += dis[to] - a[to];
        }
        
        for (auto&& to : edges[cur]) {
            if (to == fa) continue;
            dis[cur] = max(dis[cur], sum[cur] + a[to]);

            if (to == fi) {
                dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[se]);
            }
            else {
                dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[fi]);
            }
        }
        dis[cur] += a[cur];
    };
    dfs(1ll, 0ll);

    cout << dis[1] << endl;
    
}

signed main() {
    IOS;
    int t{1};
    cin >> t;
    while (t--) {
        solve();
    }


}

详细

answer.code: In lambda function:
answer.code:57:31: error: no matching function for call to ‘max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)’
   57 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[se]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:2:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:57:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   57 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[se]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:57:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   57 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[se]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:57:31: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   57 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[se]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:57:31: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   57 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[se]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:60:31: error: no matching function for call to ‘max(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)’
   60 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[fi]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:60:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   60 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[fi]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:60:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
   60 |                 dis[cur] = max(dis[cur], sum[cur] + 2ll * a[to] - dis[to] + sum[to] + a[fi]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   te...