QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#58536#4648. Average ReplacementAFewSunsWA 1552ms10488kbC++2.0kb2022-10-26 19:49:192022-10-26 19:49:23

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:49:23]
  • 评测
  • 测评结果:WA
  • 用时:1552ms
  • 内存:10488kb
  • [2022-10-26 19:49:19]
  • 提交

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("%.6lf\n",ans);
			}
		}
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 1552ms
memory: 10488kb

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.500000
1.500000
1.500000
1.500000
3.500000
3.500000
12861608.000000
81251431.000000
94636305.000000
97860396.000000
13361461.000000
89521381.000000
9573845.000000
5613423.000000
65053967.000000
22867045.000000
63074541.000000
7376557.000000
68562801.000000
21216095.000000
78889305.000000
34739974....

result:

wrong answer 39th lines differ - expected: '54505249.000000', found: '51868511.000000'