QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#100326 | #4648. Average Replacement | euphria# | WA | 2180ms | 11236kb | C++20 | 1.4kb | 2023-04-25 16:51:47 | 2023-04-25 16:51:51 |
Judging History
answer
//B站关注 艾尔莎 喵
//All OK
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define ios ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(0);cout << fixed << setprecision(9)
#define INF 1ll*1e10
#define LNF (1ll << 60)
#define PII pair<int, int>
#define PI acos(-1)
#define ll long long
// #define ll __int128
#define int ll
#define endl '\n'
using namespace std;
const int N = 3e5 + 10;
int n, m;
long double sum[N];
ll sz[N], d[N], a[N];
int f[N];
int find(int x){
return x == f[x] ? x : f[x] = find(f[x]);
}
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; i ++)
f[i] = i, sum[i] = sz[i] = 0, d[i] = 1;
for(int i = 1; i <= n; i ++)
cin >> a[i];
for(int i = 1; i <= m; i ++){
int u, v;
cin >> u >> v;
d[u] ++, d[v] ++;
int fx = find(u), fy = find(v);
// cout << fx << ' ' << fy << endl;
if(fx != fy) f[fy] = fx;
}
for(int i = 1; i <= n; i ++){
int x = find(i);
sum[x] += a[i] * d[i];
sz[x] += d[i];
}
for(int i = 1; i <= n; i ++){
int x = find(i);
cout << (double)(sum[x] / sz[x]) << endl;
}
}
signed main(){
ios;
// init();
int _ = 1;
cin >> _;
for(int __ = 1; __ <= _; __ ++){
// cout << "Case " << __ << ": ";
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2180ms
memory: 11236kb
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.500000000 1.500000000 1.500000000 1.500000000 3.500000000 3.500000000 12861608.000000000 81251431.000000000 94636305.000000000 97860396.000000000 13361461.000000000 89521381.000000000 9573845.000000000 5613423.000000000 65053967.000000000 22867045.000000000 63074541.000000000 7376557.000000000 685...
result:
wrong answer 1st lines differ - expected: '1.500000', found: '1.500000000'