QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#718518 | #9532. 长野原龙势流星群 | yaoyanfeng | 0 | 184ms | 18544kb | C++14 | 850b | 2024-11-06 20:43:52 | 2024-11-06 20:43:53 |
Judging History
answer
#include <bits/stdc++.h>
#define db long double
#define int long long
using namespace std;
const int N = 200200;
int n;
int fa[N], w[N];
int f[N];
int find(int x) {
if (x == f[x]) return x;
return f[x] = find(f[x]);
}
#define pdi pair<db, int>
priority_queue<pdi> pq;
int g[N], s[N];
signed main() {
scanf("%lld", &n);
for (int i = 1; i < n; ++i) scanf("%lld", fa + i + 1);
for (int i = 1; i <= n; ++i) scanf("%lld", w + i), g[i] = w[i], f[i] = i, s[i] = 1, pq.emplace(w[i], i);
while (!pq.empty()) {
int u = pq.top().second, o = find(u); pq.pop();
if (o == 1 || o != u) continue;
int l = find(fa[o]);
s[l] += s[o], g[l] += g[o], f[o] = l, pq.emplace(1.0 * g[l] / s[l], l);
}
for (int i = 1; i <= n; ++i) printf("%.6Lf\n", 1.0L * g[i] / s[i]);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 10172kb
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:
468078856.400500 887174926.000000 881025216.709677 912609654.666667 872318573.500000 831791515.153846 867874850.000000 892392319.166667 836427216.000000 869519853.800000 693335785.375000 925100890.000000 994728511.500000 950304719.000000 808673189.250000 866832100.571429 963096715.000000 919109808.0...
result:
wrong answer 1st numbers differ - expected: '883838885.9230770', found: '468078856.4005000', error = '0.4704025'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 184ms
memory: 18544kb
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:
474888348.125340 794937150.351351 794843085.477612 804131414.226415 805846267.166667 806376230.000000 778037203.690476 815562308.150000 776087995.601266 809328819.588235 767722826.595376 771619640.696970 800107654.476923 879639965.333333 775670912.436975 772183642.833333 854701834.666667 749291531.7...
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '474888348.1253400', error = '0.4008063'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%