QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#697888 | #9532. 长野原龙势流星群 | XXG | 0 | 104ms | 16348kb | C++14 | 1.5kb | 2024-11-01 16:16:29 | 2024-11-01 16:16:30 |
Judging History
answer
//
// Created by 15411 on 2024/10/12.
//
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define Emdl "\n"
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
using namespace std;
const int MAX = 2e5 + 7;
const int INF = 1e18 + 7;
struct p {
double sum;//平均值
ll val;//总价值
ll num;//个数
} dp[MAX];
vector<ll> edge[MAX];
bool cmp(p x, p y) {
return x.sum > y.sum;
}
void dfs(ll u) {
vector<p> now;
for (auto v: edge[u]) {
dfs(v);
now.push_back(dp[v]);
}
sort(now.begin(), now.end(), cmp);
for (auto nxt: now) {
ll val = dp[u].val + nxt.val;
ll num = dp[u].num + nxt.num;
double sum = 1.0 * val / num;
if (sum > dp[u].sum) {
dp[u].num = num;
dp[u].val = val;
dp[u].sum = sum;
}
}
}
void solve() {
ll n;
cin >> n;
for (ll i = 2; i <= n; i++) {
ll u;
cin >> u;
edge[u].push_back(i);
}
for (ll i = 1; i <= n; i++) {
cin >> dp[i].val;
dp[i].num = 1;
dp[i].sum = dp[i].val / dp[i].num;
}
dfs(1);
for (ll i = 1; i <= n; i++) {
cout << dp[i].sum << endl;
}
}
signed main() {
ios::sync_with_stdio(false);//cin.tie(0);cout.tie(0);
ll t;
t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 9524kb
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:
8.78341e+08 8.79173e+08 8.48557e+08 9.1261e+08 8.72319e+08 8.16339e+08 8.50251e+08 8.58217e+08 8.12961e+08 8.66017e+08 6.93336e+08 9.21947e+08 9.94729e+08 9.50305e+08 8.08673e+08 8.66832e+08 9.63097e+08 9.1911e+08 7.75287e+08 8.4974e+08 9.04945e+08 8.74464e+08 6.99283e+08 8.22773e+08 7.45417e+08 7.9...
result:
wrong answer 1st numbers differ - expected: '883838885.9230770', found: '878341000.0000000', error = '0.0062205'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 104ms
memory: 16348kb
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:
6.8688e+08 5.63545e+08 6.93706e+08 6.18391e+08 7.46643e+08 8.06376e+08 6.98219e+08 6.99585e+08 6.17427e+08 7.00325e+08 6.91212e+08 7.22381e+08 6.31631e+08 8.57291e+08 7.09516e+08 6.20735e+08 8.54702e+08 6.33277e+08 6.86188e+08 9.81485e+08 6.86967e+08 5.6009e+08 6.82334e+08 6.91833e+08 6.69207e+08 6....
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '686880000.0000000', error = '0.1333244'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%