QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#715855 | #9532. 长野原龙势流星群 | konata2828 | 0 | 222ms | 15268kb | C++14 | 1.0kb | 2024-11-06 13:35:17 | 2024-11-06 13:35:17 |
Judging History
answer
// Hydro submission #672b0012a059678966635824@1730871315027
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e5+5;
int n;
int fa[N];
int f[N];
ll w[N],si[N];
double ans[N];
struct node{
ll w,si;
int id;
node()=default;
node(ll w,ll si,int id):w(w),si(si),id(id){}
bool operator<(const node& ls)const{
return w*ls.si<ls.w*si;
}
};
priority_queue<node> q;
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main(){
cin>>n;
for(int i=2;i<=n;++i)cin>>fa[i];
for(int i=1;i<=n;++i){
f[i]=i;
cin>>w[i];
si[i]=1;
q.emplace(w[i],1,i);
}
while(!q.empty()){
auto it=q.top();
q.pop();
if(it.w!=w[it.id])continue;
ans[it.id]=1.0*it.w/it.si;
int to=find(fa[it.id]);
if(!to)continue;
f[it.id]=to;
w[to]+=it.w;
si[to]+=it.si;
q.emplace(w[to],si[to],fa[it.id]);
}
for(int i=1;i<=n;++i)printf("%.10f\n",ans[i]);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 8144kb
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:
482657962.1279670000 882579591.8679245710 880413995.8285714388 912609654.6666666269 872318573.5000000000 829286438.9444444180 865754793.0000000000 889720362.3448275328 831875890.9333332777 869519853.7999999523 693335785.3750000000 913423380.5000000000 994728511.5000000000 950304719.0000000000 808673...
result:
wrong answer 1st numbers differ - expected: '883838885.9230770', found: '482657962.1279670', error = '0.4539073'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 222ms
memory: 15268kb
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:
723517026.0708861351 734563864.7352941036 705685440.0941176414 743901301.7121212482 746642876.0000000000 806376230.0000000000 707480387.8902438879 750828753.5692307949 687199400.7471264601 0.0000000000 704292116.2619047165 722381415.0000000000 692101227.3877551556 715877630.5211267471 715427371.8518...
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '723517026.0708861', error = '0.0870973'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%