// Hydro submission #672b1db0a059678966636aea@1730878896563
#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}#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;
}