QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#716643 | #9532. 长野原龙势流星群 | konata2828 | 0 | 321ms | 15208kb | C++23 | 1.1kb | 2024-11-06 15:42:46 | 2024-11-06 15:42:50 |
Judging History
answer
// Hydro submission #672b1df3a059678966636b90@1730878964538
#include <bits/stdc++.h>
using LL = long long;
constexpr int N = 200005;
int n;
LL a[N];
int fa[N], par[N], size[N];
double ans[N];
struct Frac {
LL x, y;
friend bool operator<(Frac a, Frac b) { return __int128(a.x) * b.y < __int128(b.x) * a.y; }
};
int get_par(int x) { return par[x] == x ? x : par[x] = get_par(par[x]); }
int main() {
std::cin >> n;
for (int i = 2; i <= n; i++) std::cin >> fa[i];
for (int i = 1; i <= n; i++) std::cin >> a[i];
std::priority_queue<std::pair<Frac, int>> que;
std::fill_n(size + 1, n, 1);
std::iota(par + 1, par + n + 1, 1);
for (int i = 1; i <= n; i++) que.push({{a[i], size[i]}, i});
while (que.size()) {
auto [v, x] = que.top();
que.pop();
if (v.y != size[x]) continue;
ans[x] = 1. * v.x / v.y;
if (fa[x]) {
int y = get_par(fa[x]);
a[y] += a[x];
size[y] += size[x];
que.push({{a[y], size[y]}, y});
}
}
for (int i = 1; i <= n; i++) printf("%.10lf\n", ans[i]);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 8288kb
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:
1135498504.6214730740 -4479721097.5624904633 4664064751.5890951157 703904419.9681361914 681329789.6283891201 646058758.7986254692 716328314.3084403276 790542667.0150464773 601190183.8227403164 709578306.2138836384 432175710.0714285970 685743711.5180722475 701259322.8343870640 706517090.1537345648 52...
result:
wrong answer 1st numbers differ - expected: '883838885.9230770', found: '1135498504.6214731', error = '0.2847347'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 321ms
memory: 15208kb
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:
-5133621246.2596979141 1811696220.4366686344 9087959018.1714611053 -11301235341.4278926849 18839823436.2248840332 6069772814.9010877609 13704780253.7718486786 -5719557263.6830005646 -84154009143.9505920410 1262553810.9405839443 -3311959815.3668932915 -397901539.7618995905 4247842030.5720839500 38200...
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '-5133621246.2596979', error = '7.4773825'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%