QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#662453 | #6438. Crystalfly | kukka | Compile Error | / | / | C++20 | 1.9kb | 2024-10-21 00:42:40 | 2024-10-21 00:42:40 |
Judging History
This is the latest submission verdict.
- [2024-10-21 00:42:40]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-21 00:42:40]
- Submitted
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,0ll), t(n+1,0ll);
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,0ll), mx(n+1,0ll), sum(n+1,0ll);
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();
}
#ifdef _WIN64
system("pause");
#endif
}
详细
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...