QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#884126 | #7588. Monster Hunter | WTR2007 | Compile Error | / | / | C++20 | 2.3kb | 2025-02-05 21:26:50 | 2025-02-05 21:26:58 |
Judging History
This is the latest submission verdict.
- [2025-02-05 21:26:58]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-02-05 21:26:50]
- Submitted
answer
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define MULT_TEST 1
using namespace std;
typedef long double ldb;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int N = 100005;
int f[N], x[N], y[N];
bool vis[N];
vector<int> e[N];
struct node {
int a, b, id;
bool operator < (const Node &A) const {
if (a > b && A.a <= A.b) return 1;
if (a <= b && A.a > A.b) return 0;
if (a > b && A.a > A.b) return b <= A.b;
else return a > A.a;
}
};
struct dsu {
vector<int> fa;
dsu(int n) : fa(n + 2) { iota(fa.begin(), fa.end(), 0); };
inline int Find(int r) {
while (r != fa[r]) r = fa[r] = fa[fa[r]];
return r;
}
inline bool Merge(int x, int y) {
x = Find(x); y = Find(y);
if (x == y) return true;
else return fa[y] = x, false;
}
};
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
inline void DFS(int x) {
for (auto u : e[x]) {
if (u == f[x]) continue;
f[u] = x, DFS(u);
}
}
inline void Solve() {
int n;
n = read();
priority_queue<node> q;
vis[1] = 1;
for (int i = 2; i <= n; i++) {
x[i] = read(), y[i] = read();
q.push((node){x[i], y[i], i});
}
for (int i = 1; i < n; i++) {
int u = read(), v = read();
e[u].push_back(v), e[v].push_back(u);
}
DFS(1);
dsu A(n);
while (!q.empty()) {
auto [a, b, id] = q.top(); q.pop();
if (vis[id] || a != x[id] || b != y[id]) continue;
vis[id] = 1;
int top = A.Find(f[id]);
x[top] = max(x[top], x[top] - y[top] + x[id]);
y[top] = y[top] - x[id] + y[id];
q.push((node){x[top], y[top], top});
A.fa[id] = top;
}
printf("%lld\n", x[1]);
for (int i = 1; i <= n; i++)
e[i].clear(), f[i] = x[i] = y[i] = vis[i] = 0;
}
signed main() {
int _ = 1;
#if MULT_TEST
_ = read();
#endif
while (_--) Solve();
return 0;
}
详细
answer.code:17:28: error: ‘Node’ does not name a type; did you mean ‘node’? 17 | bool operator < (const Node &A) const { | ^~~~ | node answer.code: In member function ‘bool node::operator<(const int&) const’: answer.code:18:24: error: request for member ‘a’ in ‘A’, which is of non-class type ‘const int’ 18 | if (a > b && A.a <= A.b) return 1; | ^ answer.code:18:31: error: request for member ‘b’ in ‘A’, which is of non-class type ‘const int’ 18 | if (a > b && A.a <= A.b) return 1; | ^ answer.code:19:25: error: request for member ‘a’ in ‘A’, which is of non-class type ‘const int’ 19 | if (a <= b && A.a > A.b) return 0; | ^ answer.code:19:31: error: request for member ‘b’ in ‘A’, which is of non-class type ‘const int’ 19 | if (a <= b && A.a > A.b) return 0; | ^ answer.code:20:24: error: request for member ‘a’ in ‘A’, which is of non-class type ‘const int’ 20 | if (a > b && A.a > A.b) return b <= A.b; | ^ answer.code:20:30: error: request for member ‘b’ in ‘A’, which is of non-class type ‘const int’ 20 | if (a > b && A.a > A.b) return b <= A.b; | ^ answer.code:20:47: error: request for member ‘b’ in ‘A’, which is of non-class type ‘const int’ 20 | if (a > b && A.a > A.b) return b <= A.b; | ^ answer.code:21:27: error: request for member ‘a’ in ‘A’, which is of non-class type ‘const int’ 21 | else return a > A.a; | ^ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from answer.code:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of ‘constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = node]’: /usr/include/c++/14/bits/predefined_ops.h:196:23: required from ‘constexpr bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<node*, std::vector<node, std::allocator<node> > >; _Value = node; _Compare = std::less<node>]’ 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:140:48: required from ‘constexpr void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<node*, vector<node, allocator<node> > >; _Distance = long int; _Tp = node; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<node> >]’ 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:216:23: required from ‘constexpr void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<node*, vector<node, allocator<node> > >; _Compare = less<node>]’ 216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1), | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:16: required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = node; _Sequence = std::vector<node, std::allocator<node> >; _Compare = std::less<node>; value_type = node]’ 747 | std::push_heap(c.begin(), c.end(), comp); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:63:15: required from here 63 | q.push((node){x[i], y[i], i}); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for ‘operator<’ (operand types are ‘const node’ and ‘const node’) 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1023:5: note: candidate: ‘template<class _T1, class _T2, class _U1, class _U2> constexpr std::common_comparison_category_t<decltype (std::__detail::__synth3way(declval<_T1&>(), declval<_U1&>())), decltype (std::__detail::__synth3way(declval<_T2&>(), declval<_U2&>()))> std::operator<=>(const pair<_T1, _T2>&, const pair<_U1, _U2>&)’ (reversed) 1023 | operator<=>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) | ^~~~~~~~ /u...