QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#854182 | #9532. 长野原龙势流星群 | jryggs | 0 | 127ms | 13372kb | C++14 | 1002b | 2025-01-11 22:15:32 | 2025-01-11 22:15:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
int n,fa[N],c[N];
long long w[N];
bool vis[N];
long double ans[N];
struct node{
long long sum;
int num,id;
inline bool operator<(const node b)const{
if((__int128)sum*b.num != (__int128)b.sum*num)return (__int128)sum*b.num<(__int128)b.sum*num;
return id<b.id;
}
};
priority_queue<node>q;
int main(){
n=read();
for(int i = 2;i<=n;i++)fa[i]=read();
for(int i = 1;i<=n;i++)w[i]=read(),q.push({w[i],1,i}),c[i]=1;
while(q.size()){
auto [sum,num,id]=q.top();q.pop();
if(vis[id])continue;
vis[id]=1;
ans[id]=(long double)sum/num;
if(id!=1&&!vis[fa[id]]){
w[fa[id]]+=w[id],c[fa[id]]+=c[id];
q.push({w[fa[id]],c[fa[id]],fa[id]});
}
}
for(int i = 1;i<=n;i++)printf("%.7Lf\n",ans[i]);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 7988kb
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:
878341451.1578947 879173186.6363636 848557303.2272727 912609654.6666667 872318573.5000000 816339179.0000000 850251397.5555556 858217450.2352941 812960827.3636364 866017059.7777778 693335785.3750000 921947345.6666667 994728511.5000000 950304719.0000000 808673189.2500000 866832100.5714286 963096715.00...
result:
wrong answer 1st numbers differ - expected: '883838885.9230770', found: '878341451.1578947', error = '0.0062200'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 127ms
memory: 13372kb
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:
686880396.2941176 563544686.1428571 693705743.1515152 618391182.8000000 746642876.0000000 806376230.0000000 698219365.7419355 699584745.7500000 617426841.1935484 700325141.0000000 691212027.0000000 722381415.0000000 631630674.3333333 857291392.5000000 709515816.6428571 620735049.1818182 854701834.66...
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '686880396.2941176', error = '0.1333239'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%