QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#883809 | #9904. 最小生成树 | Limury | Compile Error | / | / | C++14 | 1.2kb | 2025-02-05 19:05:36 | 2025-02-05 19:05:45 |
Judging History
This is the latest submission verdict.
- [2025-02-05 19:05:45]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-02-05 19:05:36]
- Submitted
answer
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
#define mk make_pair
using namespace std;
const int MAXN = 5e5 + 5, INF = 1e9;
int n, len, num1, mst = 0;
int a[MAXN], mp[MAXN], fa[MAXN], si[MAXN];
void Make_set() {
for (int i = 1; i <= n; i ++)
fa[i] = i, si[i] = 1;
}
int Find_set(int x) {
return fa[x] == x ? x : fa[x] = Find_set(fa[x]);
}
bool cmp(int x, int y) {
return a[x] == a[y] ? x > y : a[x] < a[y];
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n, len = 2 * n - 1;
Make_set();
for (int i = 3; i <= len; i ++) mp[i] = i;
for (int i = 3; i <= len; i ++) cin >> a[i];
sort(mp + 3, mp + len + 1, cmp);
for (int i = 3; i <= len; i ++){
int num2 = 0;
for (int j = max(1, mp[i] - n); j * 2 < mp[i]; j ++){
int f1 = Find_set(j), f2 = Find_set(mp[i] - j);
if (f1 == f2) num2 ++;
else {
if (si[f1] > si[f2]) swap(f1, f2);
fa[f1] = f2, si[f2] += si[f1];
mst += a[mp[i]];
}
num1 ++;
if (num1 > 1e9 || (num2 > 1e3 && num1 >= 1e6)) break;
}
}
printf("%d\n", mst);
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:38:33: error: no matching function for call to ‘max(int, long long int)’ 38 | for (int j = max(1, mp[i] - n); j * 2 < mp[i]; j ++){ | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/14/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++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:38:33: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 38 | for (int j = max(1, mp[i] - n); j * 2 < mp[i]; j ++){ | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/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++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5705:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’ 5705 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5705:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5715:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’ 5715 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5715:5: note: template argument deduction/substitution failed: answer.code:38:33: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 38 | for (int j = max(1, mp[i] - n); j * 2 < mp[i]; j ++){ | ~~~^~~~~~~~~~~~~~ answer.code:50:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 50 | printf("%d\n", mst); | ~^ ~~~ | | | | int long long int | %lld