Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
额,G++容易自带WA Buff,珍惜生命,交C++#include<bitset> #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; const int N = 105; int T, n, m, cnt[N]; bitset<N> G[N]; double init[N]; signed main(void) { for (scanf("%d", &T); T; T--, putchar('\n')) { scanf("%d%d",&n,&m); memset(cnt, 0, sizeof(cnt)); for (int i = 1; i <= n; i++)scanf("%lf", init + i), G[i].reset(), G[i][i] = true; for (int i = 1, x, y; i <= m; i++)scanf("%d%d", &x, &y), G[x][y] = G[y][x] = true; for (int i = 1; i <= n; i++)cnt[i] = G[i].count() - 1; for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) G[i][j] = G[i][j] | G[i][k] & G[k][j]; for (int i = 1; i <= n; i++) { double ans = 0.0; int Cnt = 0; for (int j = 1; j <= n; j++) if (G[i][j])ans += init[j], Cnt += cnt[j]; printf("%.3lf\n", Cnt ? ans*cnt[i] / (double)Cnt : ans); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator