General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
252175750 Practice:
DisconnectedGraph
1060F - 11 C++17 (GCC 7-32) Accepted 15 ms 388 KB 2024-03-19 08:14:28 2024-03-19 08:14:28
→ Source
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) >> 1)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;

int in(void) { int x; scanf("%d", &x); return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); } 
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); } 
const int kN = 55;
int n = in();
vector<int> g[kN];
using Poly = vector<double>;
Poly f[kN];
Poly integral(Poly A) {
	vector<double> ans(A.size() + 1);
	_rep(i,0,A.size() - 1) ans[i + 1] = A[i] * 1. / (i + 1);
	return ans;
}
Poly operator + (const Poly &a, const Poly &b) {
	Poly c(max(a.size(), b.size()));
	_rep(i,0,c.size() - 1)	
		c[i] = (i < a.size() ? a[i] : 0.0) + (i < b.size() ? b[i] : 0.0);
	return c;
}
Poly operator * (const Poly &a, const Poly &b) {
	Poly c(a.size() + b.size() - 1);
	_rep(i,0,a.size() - 1)
		_rep(j,0,b.size() - 1)
			c[i + j] += a[i] * b[j];
	return c;
}
double evaluate(const Poly &a, double x) {
	double ans = 0, m = 1;
	for(auto &v : a) ans += v * m, m *= x;
	return ans;
}
void dfs(int u, int fa) {
	f[u].clear(); f[u].push_back(1);	
	for(auto &v : g[u]) if(v != fa) {
		dfs(v, u);
		Poly A = f[v], B = integral(f[v]);
		A.insert(A.begin(), 0); //乘以 x
		double tmp = evaluate(B, 1);
		for(auto &a : B) a = -a;
		B[0] += tmp;
		for(auto &a : B) a /= 2;
		f[u] = f[u] * (A + B);
	}
}
int main() { 
	_rep(i,2,n) {
		int u = in(), v = in();
		g[u].emplace_back(v), g[v].emplace_back(u);
	}
	_rep(i,1,n) {
		dfs(i, 0);
		printf("%.10lf\n", evaluate(f[i], 0));
	}
	return 0;
}

/* 
a list of keywords
clear empty push_back pop_back push pop top front back
emplace_back emplace push_front pop_front insert erase
find count set reset bitset map vector string multiset
first second iterator prev next deque multimap reverse
sort begin end list modify query init check calc prime
putchar getchar puts scanf printf max min swap replace
make_pair make_tuple numeric_limits auto function null
*/
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details