QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#828614 | #9532. 长野原龙势流星群 | no_zzz_is_wwbnd | 0 | 143ms | 40264kb | C++14 | 1.6kb | 2024-12-23 18:51:46 | 2024-12-23 18:51:51 |
Judging History
answer
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
#define int long long
#define PII pair<int,int>
#define x first
#define y second
#define For(i, l, r) for(int i = l; i <= r; i ++)
#define Rep(i, l, r) for(int i = l; i >= r; i --)
bool START;
void in(int &x)
{
char c = getchar(); int op = 1;
while(c > '9' || c < '0') op *= (c == '-' ? -1 : 1), c = getchar();
for(x = 0; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; x *= op;
}
const int N = 2e5 + 50;
int n, m, a[N], sz[N], f[N];
vector<int> G[N];
priority_queue<PII> q[N];
bool operator < (PII a, PII b) {return a.x * b.y <= b.x * a.y;}
void dfs(int u, int pa)
{
for(int v : G[u]) if(v != pa)
{
dfs(v, u);
if(q[u].size() < q[v].size()) swap(q[u], q[v]);
while(q[v].size()) q[u].push(q[v].top()), q[v].pop();
}
sz[u] = 1; f[u] = a[u];
while(q[u].size() && f[u] * q[u].top().y <= sz[u] * q[u].top().x)
{
f[u] += q[u].top().x; sz[u] += q[u].top().y; q[u].pop();
}
q[u].push({f[u], sz[u]});
}
bool ENDPOS = 0;
signed main()
{
double BeginTime = clock();
in(n); For(i, 2, n)
{
int x; in(x); G[x].push_back(i);
}
For(i, 1, n) in(a[i]);
dfs(1, 0);
For(i, 1, n)
{
printf("%.8lf\n", 1.0 * f[i] / sz[i]);
}
cerr << "Time = " << (clock() - BeginTime) * 1.0 / CLOCKS_PER_SEC << " s" << endl;
cerr << "Memory = " << (&ENDPOS - &START) * 1.0 / 1024 / 1024 << " Mib" << endl;
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 18684kb
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:
816121026.91891897 812439186.72972977 817453144.99090910 851299232.00000000 731034958.89473689 735820064.11111116 824613597.48000002 822295699.18348622 736454844.90909088 840887570.31818187 693335785.37500000 925100890.00000000 991367311.00000000 864476699.00000000 808673189.25000000 840185658.71875...
result:
wrong answer 1st numbers differ - expected: '883838885.9230770', found: '816121026.9189190', error = '0.0766179'
Subtask #2:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 143ms
memory: 40264kb
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:
600919427.07212949 605248551.57072937 596792539.36625934 605384893.88875449 746642876.00000000 806376230.00000000 598213013.60966980 605762336.94309926 596878739.72222221 605135160.04884005 691212027.00000000 722381415.00000000 589572439.72488260 735461880.00000000 598843991.56316411 606212674.95272...
result:
wrong answer 1st numbers differ - expected: '792545632.4154930', found: '600919427.0721295', error = '0.2417857'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #2:
0%