QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#689548 | #9532. 长野原龙势流星群 | ANIG | 0 | 875ms | 12200kb | C++14 | 709b | 2024-10-30 17:40:41 | 2024-10-30 17:40:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int n,fa[N],w[N],mk[N];
vector<int>p[N];
double f[N],nw;
bool cmp(int a,int b){
return f[a]>f[b];
}
void dfs(int x){
mk[x]=1;
f[x]=w[x]-nw;
for(auto c:p[x]){
if(mk[c])continue;
dfs(c);
if(f[c]>0)f[x]+=f[c];
}
mk[x]=0;
}
signed main(){
cin>>n;
for(int i=2;i<=n;i++){
scanf("%lld",&fa[i]);
p[fa[i]].push_back(i);
p[i].push_back(fa[i]);
}
for(int i=1;i<=n;i++)scanf("%lld",&w[i]);
for(int i=1;i<=n;i++){
double l=0,r=1e9;
for(int j=1;j<=50;j++){
double mid=(l+r)/2;
nw=mid;
dfs(i);
if(f[i]>=0)l=mid;
else r=mid;
}
printf("%.10lf\n",l);
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 875ms
memory: 12200kb
input:
2000 1 2 2 4 5 2 3 6 4 2 7 2 8 14 8 12 1 14 4 14 8 18 9 2 7 22 20 22 14 29 28 16 6 21 23 6 21 14 13 9 1 4 18 13 2 39 21 33 18 20 38 27 27 1 49 5 51 3 31 24 10 42 2 44 13 9 35 66 27 60 67 59 29 40 53 2 33 43 26 43 62 16 78 45 14 10 73 69 41 35 25 26 2 70 54 1 54 48 5 36 44 28 90 29 51 51 93 82 95 45 ...
output:
883838885.9230761528 887174925.9999992847 883171740.0208328962 912609654.6666665077 891981335.4999997616 878800320.1228065491 880139482.5081965923 892392319.1666665077 873582146.5394728184 882058307.6153845787 870362662.9999998808 925100889.9999995232 994728511.4999998808 950304718.9999998808 905172...
result:
wrong answer 3rd numbers differ - expected: '881025216.7096770', found: '883171740.0208329', error = '0.0024364'
Subtask #2:
score: 0
Time Limit Exceeded
Test #32:
score: 0
Time Limit Exceeded
input:
200000 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%