QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#789034 | #7588. Monster Hunter | KFC | Compile Error | / | / | C++98 | 1.6kb | 2024-11-27 19:06:52 | 2024-11-27 19:06:52 |
Judging History
answer
// Hydro submission #6746fd4a9592d6097b86cbbd@1732705611121
#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) {
if((a[x]<=b[x])!=(a[y]<=b[y])) return (a[x]>b[x]);
if(a[x]<=b[x]) return a[x]>a[y];
return b[x]<b[y];
}
};
int fa[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]); }
bool memory2;
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
cin>>n;
priority_queue<int,vector<int>,cmp> q;
for(int i=2;i<=n;i++) cin>>a[i]>>b[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);
for(int i=1;i<=n;i++) f[i]=i;
for(int i=2;i<=n;i++) q.push(i);
ll v1=0,v2=0;
while(q.size()) {
int x=q.top(); q.pop();
int y=find(fa[x]);
// cerr<<x<<" "<<y<<endl;
if(y!=1) {
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];
// cerr<<"Upd "<<y<<" "<<a[y]<<" "<<b[y]<<endl;
}
else {
v2=max(v2,a[x]-v1);
v1=v1-a[x]+b[x];
}
f[x]=y;
}
cout<<v2<<endl;
#ifdef xxzx
cerr<<"Time: "<<clo<<"MS"<<endl;
cerr<<"Memory: "<<abs(&memory1-&memory2)/1024./1024.<<"MB"<<endl;
#endif
return 0;
}
Details
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: In member function ‘bool cmp::operator()(const int&, const int&)’: answer.code:17:13: error: ‘a’ was not declared in this scope 17 | if((a[x]<=b[x])!=(a[y]<=b[y])) return (a[x]>b[x]); | ^ answer.code:17:19: error: ‘b’ was not declared in this scope 17 | if((a[x]<=b[x])!=(a[y]<=b[y])) return (a[x]>b[x]); | ^ answer.code:18:12: error: ‘a’ was not declared in this scope 18 | if(a[x]<=b[x]) return a[x]>a[y]; | ^ answer.code:18:18: error: ‘b’ was not declared in this scope 18 | if(a[x]<=b[x]) return a[x]>a[y]; | ^ answer.code:19:16: error: ‘b’ was not declared in this scope 19 | return b[x]<b[y]; | ^ answer.code: In function ‘void dfs(int)’: answer.code:24:14: error: ‘y’ does not name a type 24 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ^ answer.code:24:51: error: expected ‘;’ before ‘}’ token 24 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ^ | ; 25 | } | ~ answer.code:25:1: error: expected primary-expression before ‘}’ token 25 | } | ^ answer.code:24:51: error: expected ‘;’ before ‘}’ token 24 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ^ | ; 25 | } | ~ answer.code:25:1: error: expected primary-expression before ‘}’ token 25 | } | ^ answer.code:24:51: error: expected ‘)’ before ‘}’ token 24 | for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y); | ~ ^ | ) 25 | } | ~ answer.code:25:1: error: expected primary-expression before ‘}’ token 25 | } | ^ answer.code: In function ‘int main()’: answer.code:30:42: error: ‘nullptr’ was not declared in this scope 30 | ios::sync_with_stdio(false), cin.tie(nullptr); | ^~~~~~~ answer.code:34:32: error: ‘a’ was not declared in this scope 34 | for(int i=2;i<=n;i++) cin>>a[i]>>b[i]; | ^ answer.code:34:38: error: ‘b’ was not declared in this scope 34 | for(int i=2;i<=n;i++) cin>>a[i]>>b[i]; | ^ answer.code:39:5: error: ‘ll’ was not declared in this scope 39 | ll v1=0,v2=0; | ^~ answer.code:45:15: error: expected ‘;’ before ‘w’ 45 | ll w=-a[x]+b[x]-a[y]+b[y]; | ^~ | ; answer.code:46:13: error: ‘a’ was not declared in this scope 46 | a[y]=max(a[y],a[x]-(-a[y]+b[y])); | ^ answer.code:46:39: error: ‘b’ was not declared in this scope 46 | a[y]=max(a[y],a[x]-(-a[y]+b[y])); | ^ answer.code:47:18: error: ‘w’ was not declared in this scope 47 | b[y]=w+a[y]; | ^ answer.code:51:13: error: ‘v2’ was not declared in this scope 51 | v2=max(v2,a[x]-v1); | ^~ answer.code:51:23: error: ‘a’ was not declared in this scope 51 | v2=max(v2,a[x]-v1); | ^ answer.code:51:28: error: ‘v1’ was not declared in this scope; did you mean ‘y1’? 51 | v2=max(v2,a[x]-v1); | ^~ | y1 answer.code:52:24: error: ‘b’ was not declared in this scope 52 | v1=v1-a[x]+b[x]; | ^ answer.code:56:11: error: ‘v2’ was not declared in this scope 56 | cout<<v2<<endl; | ^~