QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#698095 | #9532. 长野原龙势流星群 | XXG | 0 | 185ms | 20700kb | C++14 | 1.4kb | 2024-11-01 17:22:55 | 2024-11-01 17:22:55 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MAX = 2e5 + 7;
ll fa[MAX];//原本的父节点
ll f[MAX];//并查集父节点
struct p {
ll siz;
ll val;
ll num;
} dp[MAX];
struct cmp {
bool operator()(const p &a, const p &b) {
return a.val * b.siz < b.val * a.siz;//降序排列
}
};
std::priority_queue<p, vector<p>, cmp> q;
bool vis[MAX] = {false};
double fp[MAX];
void solve() {
ll n;
cin >> n;
fa[1] = 1;
f[1] = 1;
for (ll i = 2; i <= n; i++) {
ll u;
cin >> u;
fa[i] = u;
f[i] = i;
}
for (ll i = 1; i <= n; i++) {
cin >> dp[i].val;
dp[i].siz = 1;
dp[i].num = i;
q.push(dp[i]);
}
while (!q.empty()) {
p now = q.top();
q.pop();
if (vis[now.num])continue;
vis[now.num] = true;
fp[now.num] = 1.0 * now.val / now.siz;
ll nxt = f[fa[now.num]];
f[now.num] = nxt;
if (!vis[nxt]) {
dp[nxt].val += now.val;
dp[nxt].siz += now.siz;
q.push(dp[nxt]);
}
}
for (ll i = 1; i <= n; i++) {
cout << fp[i] << 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;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 10184kb
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.83547e+08 8.87175e+08 8.80522e+08 9.1261e+08 8.72319e+08 8.31792e+08 8.65581e+08 8.92284e+08 8.36427e+08 8.6952e+08 6.93336e+08 9.25101e+08 9.94729e+08 9.50305e+08 8.08673e+08 8.66832e+08 9.63097e+08 9.1911e+08 7.75287e+08 8.53048e+08 9.12352e+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: '883547000.0000000', error = '0.0003302'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 185ms
memory: 20700kb
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:
7.5741e+08 7.54487e+08 7.67269e+08 7.37164e+08 7.71547e+08 8.06376e+08 7.41979e+08 7.45992e+08 7.40133e+08 7.7222e+08 7.40469e+08 7.51684e+08 7.77521e+08 8.7964e+08 7.45937e+08 7.55762e+08 8.54702e+08 7.31832e+08 7.5351e+08 9.81485e+08 7.43553e+08 7.36399e+08 7.417e+08 7.52294e+08 7.33723e+08 7.9794...
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '757410000.0000000', error = '0.0443326'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%