QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#716739#9532. 长野原龙势流星群lc201108020 191ms30172kbC++14921b2024-11-06 15:56:122024-11-06 15:56:12

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 15:56:12]
  • 评测
  • 测评结果:0
  • 用时:191ms
  • 内存:30172kb
  • [2024-11-06 15:56:12]
  • 提交

answer

#include <bits/stdc++.h>
#define double long double
using namespace std;

const int N = 2e5 + 5;
const double eps = 1e-9;
int n, w[N], cnt[N], ans[N];
vector<int> g[N];
priority_queue<pair<double, int> > hep[N];

void dfs(int u){
	cnt[u] = 1;
	for(int v : g[u]){
		dfs(v);
		hep[u].push(make_pair((double)(ans[v]) / cnt[v], v));}
	while(!hep[u].empty()){
		if(hep[u].top().first <= (double)(ans[u]) / cnt[u] - eps)
			break;
		int v = hep[u].top().second; hep[u].pop();
		cnt[u] += cnt[v], ans[u] += ans[v];
		if(hep[u].size() < hep[v].size()) swap(hep[u], hep[v]);
		while(!hep[v].empty()) hep[u].push(hep[v].top()), hep[v].pop();
	}
	return ;
}

signed main(){
	cin >> n;
	for(int i = 2, p; i <= n; i++)
		cin >> p, g[p].push_back(i);
	for(int i = 1; i <= n; i++) cin >> ans[i];
	
	dfs(1);
	
	for(int i = 1; i <= n; i++)
		printf("%.10Lf\n", (double)(ans[i]) / cnt[i]);
	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: 2ms
memory: 15552kb

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:

-1420971.2577903683
6702855.0735294118
6301518.9863481229
74038596.8500000000
-3107784.5333333333
-931544.0555555556
706859501.3333333333
72675430.4782608696
13268835.8676470588
-576472.6721311475
-27999357.3571428571
-17579442.2000000000
994728511.5000000000
-7511183.0122448980
76956819.4736842105
...

result:

wrong answer 1st numbers differ - expected: '883838885.9230770', found: '-1420971.2577904', error = '1.0016077'

Subtask #2:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 191ms
memory: 30172kb

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:

501428216.5000000000
514689638.6666666667
203830.6249201958
293616931.0000000000
746642876.0000000000
806376230.0000000000
63774687.0000000000
234233479.0000000000
199071.3342526200
-179075.7645202020
691212027.0000000000
722381415.0000000000
394755540.0000000000
31125868.8750000000
10599.4646316407...

result:

wrong answer 1st numbers differ - expected: '792545632.4154930', found: '501428216.5000000', error = '0.3673194'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #2:

0%