QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#789374 | #7588. Monster Hunter | KFC | Compile Error | / | / | C++98 | 1.7kb | 2024-11-27 20:05:26 | 2024-11-27 20:05:26 |
Judging History
answer
// Hydro submission #67470b049592d6097b86ef6d@1732709124096
#include <bits/stdc++.h>
using namespace std;
#define clo 1000.*clock()/CLOCKS_PER_SEC
#ifndef xxzx
#define endl '\n'
#endif
using ll=long long;
using PII=pair<int,int>;
const int N=1e5+10;
bool memory1;
int n;
ll a[N],b[N];
vector<int> eg[N];
// struct cmp {
// bool operator()(const int &x,const int &y) {
// }
// };
struct node {
ll a,b,i;
friend bool operator>(node x,node y) {
if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b);
if(x.a<=x.b) return x.a>y.a;
return x.b<y.b;
}
};
int fa[N],vis[N];
void dfs(int x) {
for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y);
}
int f[N];
int find(int x) { return (x==f[x])? x:f[x]=find(f[x]); }
void solve() {
cin>>n;
priority_queue<node,vector<node>,greater<node>> q;
for(int i=1;i<=n;i++) eg[i].clear(),f[i]=i,vis[i]=0;
for(int i=2;i<=n;i++) cin>>a[i]>>b[i],q.push((node){a[i],b[i],i});
for(int i=1,x,y;i<n;i++) cin>>x>>y,eg[x].push_back(y),eg[y].push_back(x);
dfs(1);
a[1]=b[1]=0;
vis[1]=1;
while(q.size()) {
node now=q.top(); q.pop();
int x=now.i;
if(a[x]!=now.a||b[x]!=now.b||vis[x]) continue;
vis[x]=1;
int y=find(fa[x]);
ll w=-a[x]+b[x]-a[y]+b[y];
a[y]=max(a[y],a[x]-(-a[y]+b[y]));
b[y]=w+a[y];
q.push({a[y],b[y],y});
f[x]=y;
}
cout<<a[1]<<endl;
}
bool memory2;
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int T; cin>>T;
while(T--) solve();
#ifdef xxzx
cerr<<"Time: "<<clo<<"MS"<<endl;
cerr<<"Memory: "<<abs(&memory1-&memory2)/1024./1024.<<"MB"<<endl;
#endif
return 0;
}
详细
answer.code:8:7: error: expected nested-name-specifier before ‘ll’ 8 | using ll=long long; | ^~ answer.code:9:7: error: expected nested-name-specifier before ‘PII’ 9 | using PII=pair<int,int>; | ^~~ answer.code:13:1: error: ‘ll’ does not name a type 13 | ll a[N],b[N]; | ^~ answer.code:20:5: error: ‘ll’ does not name a type 20 | ll a,b,i; | ^~ answer.code: In function ‘bool operator>(node, node)’: answer.code:22:15: error: ‘struct node’ has no member named ‘a’ 22 | if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b); | ^ answer.code:22:20: error: ‘struct node’ has no member named ‘b’ 22 | if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b); | ^ answer.code:22:27: error: ‘struct node’ has no member named ‘a’ 22 | if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b); | ^ answer.code:22:32: error: ‘struct node’ has no member named ‘b’ 22 | if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b); | ^ answer.code:22:46: error: ‘struct node’ has no member named ‘a’ 22 | if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b); | ^ answer.code:22:50: error: ‘struct node’ has no member named ‘b’ 22 | if((x.a<=x.b)!=(y.a<=y.b)) return (x.a>x.b); | ^ answer.code:23:14: error: ‘struct node’ has no member named ‘a’ 23 | if(x.a<=x.b) return x.a>y.a; | ^ answer.code:23:19: error: ‘struct node’ has no member named ‘b’ 23 | if(x.a<=x.b) return x.a>y.a; | ^ answer.code:23:31: error: ‘struct node’ has no member named ‘a’ 23 | if(x.a<=x.b) return x.a>y.a; | ^ answer.code:23:35: error: ‘struct node’ has no member named ‘a’ 23 | if(x.a<=x.b) return x.a>y.a; | ^ answer.code:24:18: error: ‘struct node’ has no member named ‘b’ 24 | return x.b<y.b; | ^ answer.code:24:22: error: ‘struct node’ has no member named ‘b’ 24 | return x.b<y.b; | ^ answer.code: In function ‘void dfs(int)’: answer.code:29:14: error: ‘y’ does not name a type 29 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ^ answer.code:29:51: error: expected ‘;’ before ‘}’ token 29 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ^ | ; 30 | } | ~ answer.code:30:1: error: expected primary-expression before ‘}’ token 30 | } | ^ answer.code:29:51: error: expected ‘;’ before ‘}’ token 29 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ^ | ; 30 | } | ~ answer.code:30:1: error: expected primary-expression before ‘}’ token 30 | } | ^ answer.code:29:51: error: expected ‘)’ before ‘}’ token 29 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ~ ^ | ) 30 | } | ~ answer.code:30:1: error: expected primary-expression before ‘}’ token 30 | } | ^ answer.code: In function ‘void solve()’: answer.code:35:50: error: ‘>>’ should be ‘> >’ within a nested template argument list 35 | priority_queue<node,vector<node>,greater<node>> q; | ^~ | > > answer.code:37:32: error: ‘a’ was not declared in this scope 37 | for(int i=2;i<=n;i++) cin>>a[i]>>b[i],q.push((node){a[i],b[i],i}); | ^ answer.code:37:38: error: ‘b’ was not declared in this scope 37 | for(int i=2;i<=n;i++) cin>>a[i]>>b[i],q.push((node){a[i],b[i],i}); | ^ answer.code:40:5: error: ‘a’ was not declared in this scope 40 | a[1]=b[1]=0; | ^ answer.code:40:10: error: ‘b’ was not declared in this scope 40 | a[1]=b[1]=0; | ^ answer.code:44:19: error: ‘struct node’ has no member named ‘i’ 44 | int x=now.i; | ^ answer.code:45:22: error: ‘struct node’ has no member named ‘a’ 45 | if(a[x]!=now.a||b[x]!=now.b||vis[x]) continue; | ^ answer.code:45:35: error: ‘struct node’ has no member named ‘b’ 45 | if(a[x]!=now.a||b[x]!=now.b||vis[x]) continue; | ^ answer.code:48:9: error: ‘ll’ was ...