QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#58534#4648. Average ReplacementAFewSunsWA 1621ms10492kbC++2.0kb2022-10-26 19:48:542022-10-26 19:48:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-26 19:48:56]
  • 评测
  • 测评结果:WA
  • 用时:1621ms
  • 内存:10492kb
  • [2022-10-26 19:48:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
ll t,n,m,a[100010],head[100010],cnt=0,d[100010],sum1=0,sum2=0,tot=0;
bl ck[100010];
db ans;
struct node{
	ll nxt,to;
}e[200020];
void add(ll u,ll v){
	e[++cnt].nxt=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}
void dfs(ll u){
	ck[u]=1;
	sum1+=a[u]*(d[u]+1);
	sum2+=d[u]+1;
	tot++;
	go(u){
		ll v=e[i].to;
		if(!ck[v]) dfs(v);
	}
}
int main(){
	t=read();
	while(t--){
		n=read();
		m=read();
		fr(i,1,n) d[i]=head[i]=ck[i]=0;
		cnt=0;
		fr(i,1,n) a[i]=read();
		fr(i,1,m){
			ll u=read(),v=read();
			d[u]++;
			d[v]++;
			add(u,v);
			add(v,u);
		}
		fr(i,1,n){
			if(!ck[i]){
				sum1=sum2=tot=0;
				dfs(i);
				ans=1.0*sum1/sum2;
				fr(j,1,tot) pf("%.7lf\n",ans);
			}
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1621ms
memory: 10492kb

input:

100
2 1
1 2
1 2
4 2
1 2 3 4
1 2
3 4
1000 10
12861608 81251431 94636305 97860396 13361461 89521381 9573845 5613423 65053967 22867045 63074541 7376557 68562801 21216095 78889305 34739974 74647393 32495323 15113554 1391235 57948633 91911807 89671183 70279905 48099886 30931849 2289485 44602370 36977326 ...

output:

1.5000000
1.5000000
1.5000000
1.5000000
3.5000000
3.5000000
12861608.0000000
81251431.0000000
94636305.0000000
97860396.0000000
13361461.0000000
89521381.0000000
9573845.0000000
5613423.0000000
65053967.0000000
22867045.0000000
63074541.0000000
7376557.0000000
68562801.0000000
21216095.0000000
78889...

result:

wrong answer 1st lines differ - expected: '1.500000', found: '1.5000000'