Submission #1515128
Source Code Expand
#include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int N = 2e5 + 10, mod = 924844033; ll n, fact[N], inv[N], sz[N], res[N]; vector<int> adj[N]; ll power(ll a, ll b){ if(b == 0)return 1; ll ret = power(a, b/2); ret *= ret; ret %= mod; if(b % 2)ret *= a, ret %= mod; return ret; } ll comb(int n, int k){ if(k < 0 || k > n)return 0; ll ret = fact[n]; ret *= inv[k]; ret %= mod; ret *= inv[n - k]; ret %= mod; return ret; } void dfs(int v, int p = -1){ sz[v]++; for(auto u : adj[v]){ if(u == p)continue; dfs(u, v); for(int i=1; i<=sz[u]; i++) res[i] = (res[i] + mod - comb(sz[u], i)), res[i] %= mod; sz[v] += sz[u]; } for(int i=1; i<=n-sz[v]; i++) res[i] = (res[i] + mod - comb(n-sz[v], i)), res[i] %= mod; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=0; i<n-1; i++){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } fact[0] = 1; for(int i=1; i<N; i++) fact[i] = (1LL * fact[i - 1] * i) % mod; inv[N - 1] = power(fact[N - 1], mod - 2); for(int i=N-2; i>=0; i--) inv[i] = (1LL * inv[i + 1] * (i + 1)) % mod; dfs(1); for(int i=1; i<=n; i++){ res[i] += (1LL * n * comb(n, i)) % mod; res[i] %= mod; cout << res[i] << '\n'; } }
Submission Info
Submission Time | |
---|---|
Task | F - Many Easy Problems |
User | KeivanR |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1428 Byte |
Status | TLE |
Exec Time | 5260 ms |
Memory | 38016 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1900 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0, example1, example2 |
All | doublestar0, doublestar1, doublestar2, doublestar3, doublestar4, example0, example1, example2, line0, line1, line2, line3, line4, maxrand0, maxrand1, maxrand10, maxrand11, maxrand12, maxrand13, maxrand14, maxrand15, maxrand16, maxrand17, maxrand18, maxrand19, maxrand2, maxrand3, maxrand4, maxrand5, maxrand6, maxrand7, maxrand8, maxrand9, rand0, rand1, rand2, rand3, rand4, rand5, rand6, rand7, rand8, rand9, star0, star1, star2, star3, star4 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
doublestar0 | TLE | 5256 ms | 17784 KB |
doublestar1 | TLE | 5256 ms | 17784 KB |
doublestar2 | TLE | 5256 ms | 19832 KB |
doublestar3 | TLE | 5256 ms | 17784 KB |
doublestar4 | TLE | 5256 ms | 17784 KB |
example0 | AC | 7 ms | 11136 KB |
example1 | AC | 7 ms | 11136 KB |
example2 | AC | 7 ms | 11136 KB |
line0 | TLE | 5257 ms | 38016 KB |
line1 | TLE | 5258 ms | 35968 KB |
line2 | TLE | 5258 ms | 35968 KB |
line3 | TLE | 5258 ms | 35968 KB |
line4 | TLE | 5258 ms | 35968 KB |
maxrand0 | TLE | 5256 ms | 17664 KB |
maxrand1 | TLE | 5256 ms | 17664 KB |
maxrand10 | TLE | 5256 ms | 19712 KB |
maxrand11 | TLE | 5256 ms | 17664 KB |
maxrand12 | TLE | 5256 ms | 17664 KB |
maxrand13 | TLE | 5256 ms | 17664 KB |
maxrand14 | TLE | 5256 ms | 17664 KB |
maxrand15 | TLE | 5256 ms | 17664 KB |
maxrand16 | TLE | 5256 ms | 17664 KB |
maxrand17 | TLE | 5256 ms | 19712 KB |
maxrand18 | TLE | 5256 ms | 17664 KB |
maxrand19 | TLE | 5256 ms | 17664 KB |
maxrand2 | TLE | 5256 ms | 17664 KB |
maxrand3 | TLE | 5256 ms | 17664 KB |
maxrand4 | TLE | 5260 ms | 17664 KB |
maxrand5 | TLE | 5256 ms | 17664 KB |
maxrand6 | TLE | 5256 ms | 19712 KB |
maxrand7 | TLE | 5256 ms | 17664 KB |
maxrand8 | TLE | 5256 ms | 17664 KB |
maxrand9 | TLE | 5256 ms | 17664 KB |
rand0 | AC | 62 ms | 11264 KB |
rand1 | AC | 7 ms | 11264 KB |
rand2 | AC | 37 ms | 11264 KB |
rand3 | AC | 57 ms | 11264 KB |
rand4 | AC | 12 ms | 11264 KB |
rand5 | AC | 59 ms | 11264 KB |
rand6 | AC | 32 ms | 11264 KB |
rand7 | AC | 58 ms | 11264 KB |
rand8 | AC | 8 ms | 11264 KB |
rand9 | AC | 16 ms | 11264 KB |
star0 | TLE | 5256 ms | 18164 KB |
star1 | TLE | 5256 ms | 18164 KB |
star2 | TLE | 5256 ms | 18164 KB |
star3 | TLE | 5256 ms | 18164 KB |
star4 | TLE | 5256 ms | 18164 KB |