QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#623021 | #4648. Average Replacement | vision | WA | 1092ms | 16088kb | C++20 | 1.1kb | 2024-10-09 09:38:58 | 2024-10-09 09:38:58 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define lson k<<1
#define rson (k<<1)|1
#define debug cout<<666<<endl;
using namespace std;
const int N=1e6+5;
vector<int>v[N];
int f[N];
int find(int x){
if(f[x]!=x)f[x]=find(f[x]);
return f[x];
}
int si[N];
int sum[N];
int a[N];
void vision()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
f[i]=i;
cin>>a[i];
sum[i]=si[i]=0;
v[i].clear();
}
for(int j=1;j<=m;j++){
int x,y;
cin>>x>>y;
int tx=find(x),ty=find(y);
f[tx]=ty;
}
for(int i=1;i<=n;i++){
int tx=find(i);
sum[tx]+=(a[i]*((int)v[i].size()+1));
si[tx]+=((int)v[i].size()+1);
}
for(int i=1;i<=n;i++){
int tx=find(i);
double ans=(double)sum[tx]/si[tx];
cout<<fixed<<setprecision(6)<<ans<<"\n";
}
return ;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
cin>>t;
while(t--){
vision();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1092ms
memory: 16088kb
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 13106th lines differ - expected: '35012893.230769', found: '32781018.600000'