QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#715203#9532. 长野原龙势流星群konata2828Compile Error//C++98729b2024-11-06 10:50:162024-11-06 10:50:17

Judging History

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

  • [2024-11-06 10:50:17]
  • 评测
  • [2024-11-06 10:50:16]
  • 提交

answer

// Hydro submission #672ad966a05967896663408b@1730861414745
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,p[N],fa[N],sz[N];
long double w[N],ans[N];
priority_queue<pair<int,int>> pq;
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main() {
	cin>>n;
	for(int i=2; i<=n; i++) cin>>p[i];
	for(int i=1; i<=n; i++) cin>>w[i];
	for(int i=1; i<=n; i++) pq.push(make_pair(w[i],i)),fa[i]=i,sz[i]=1;
	while(!pq.empty()) {
		int u=pq.top().second;
		pq.pop();
		if(fa[u]!=u) continue;
		ans[u]=w[u]/sz[u];
		int x=fa[u]=find(p[u]);
		if(!x) continue;
		w[x]+=w[u],sz[x]+=sz[u];
		pq.push(make_pair(w[x]/sz[x],x));
	}
	for(int i=1; i<=n; i++) printf("%.10Lf\n",ans[i]);
	return 0;
}

Details

answer.code:7:28: error: ‘>>’ should be ‘> >’ within a nested template argument list
    7 | priority_queue<pair<int,int>> pq;
      |                            ^~
      |                            > >