QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676045#9532. 长野原龙势流星群Kevin53070 169ms17224kbC++141.7kb2024-10-25 20:05:532024-10-25 20:05:53

Judging History

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

  • [2024-10-25 20:05:53]
  • 评测
  • 测评结果:0
  • 用时:169ms
  • 内存:17224kb
  • [2024-10-25 20:05:53]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int n;
int p[200200];
ll w[200200],s[200200];
int fa[200200];
long double ans[200200];
int ok[200200];
struct cmp
{
	bool operator ()(pair<pair<ll,ll>,int> A,pair<pair<ll,ll>,int> B)
	{
		return A.first.first*B.first.second>A.first.second*B.first.first;
	}
};
inline int anc(int x)
{
	while(fa[x]!=x) x=fa[x]=fa[fa[x]];
	return x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=2;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		cin>>w[i];
		s[i]=1;
	}
	ok[0]=1;
	priority_queue<pair<pair<ll,ll>,int>,vector<pair<pair<ll,ll>,int>>,cmp> pq;
	for(int i=1;i<=n;i++)
		pq.emplace(mp(w[i],s[i]),i);
	while(!pq.empty())
	{
		int x=pq.top().second;
		pq.pop();
		if(ok[x]) continue;
		ok[x]=1;
		ans[x]=1.0L*w[x]/s[x];
		int y=anc(p[x]);
		if(!ok[y])
		{
			w[y]+=w[x];
			s[y]+=s[x];
			pq.emplace(mp(w[y],s[y]),y);
		}
	}
	cout<<fixed<<setprecision(10);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<'\n';
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 10072kb

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:

93916248.5789473684
68154919.2500000000
118593902.7142857143
179140487.3939393939
156546743.1666666667
160586342.2500000000
70806886.0000000000
108062640.3333333333
98131285.6666666667
173339478.5000000000
51375303.8000000000
231340037.2000000000
150064200.1428571429
115193476.2857142857
236782970.2...

result:

wrong answer 1st numbers differ - expected: '883838885.9230770', found: '93916248.5789474', error = '0.8937405'

Subtask #2:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 169ms
memory: 17224kb

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:

268186401.5000000000
106214013.0000000000
252443821.5000000000
164851071.0000000000
321827655.1333333333
355258197.8750000000
63774687.0000000000
234233479.0000000000
36085211.0000000000
267049434.3333333333
298147604.3636363636
334123424.7500000000
233065218.0000000000
353104020.5000000000
15215558...

result:

wrong answer 1st numbers differ - expected: '792545632.4154930', found: '268186401.5000000', error = '0.6616139'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #2:

0%