Problem p03991 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline T read() {
  T f = 0, x = 0;
  char c = getchar();
  while (!isdigit(c))
    f = c == '-', c = getchar();
  while (isdigit(c))
    x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 4e5 + 9, mod = 924844033;
inline int add(int x, int y) { return x + y >= mod ? x - mod + y : x + y; }
inline int sub(int x, int y) { return x >= y ? x - y : x + mod - y; }
inline int qpow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1)
      ret = 1LL * x * ret % mod;
    x = 1LL * x * x % mod, y >>= 1;
  }
  return ret;
}

int rev[N], limit, bit, Gi = qpow(5, mod - 2);
inline void prepare(int len) {
  limit = 1, bit = 0;
  while (limit < len)
    limit <<= 1, bit++;
  for (int i = 1; i < limit; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bit - 1));
}
inline void NTT(int *a, int inv) {
  for (int i = 1; i < limit; i++)
    if (i < rev[i])
      swap(a[i], a[rev[i]]);
  for (int mid = 1; mid < limit; mid <<= 1) {
    int tmp = qpow(~inv ? 5 : Gi, (mod - 1) / (mid << 1));
    for (int i = 0, R = mid << 1; i < limit; i += R)
      for (int j = 0, omega = 1; j < mid;
           j++, omega = 1LL * omega * tmp % mod) {
        int x = a[i + j], y = 1LL * omega * a[i + j + mid] % mod;
        a[i + j] = add(x, y), a[i + j + mid] = sub(x, y);
      }
  }
  if (inv == -1) {
    inv = qpow(limit, mod - 2);
    for (int i = 0; i < limit; i++)
      a[i] = 1LL * a[i] * inv % mod;
  }
}

int head[N], nex[N], to[N], cnt;
inline void adde(int u, int v) {
  nex[++cnt] = head[u];
  head[u] = cnt, to[cnt] = v;
}
int g[N], f[N], n, siz[N], num[N], fac[N], ifac[N];
inline void dfs(int u, int _f) {
  siz[u] = 1;
  for (int i = head[u]; i; i = nex[i])
    if (to[i] ^ _f)
      dfs(to[i], u), siz[u] += siz[to[i]], num[siz[to[i]]]++;
  num[n - siz[u]]++;
}

inline int C(int _n, int _m) {
  if (_n < 0 || _m < 0 || _n < _m)
    return 0;
  return 1LL * fac[_n] * ifac[_m] % mod * ifac[_n - _m] % mod;
}

int main() {
  n = read<int>();
  for (int i = 1; i < n; i++) {
    int u = read<int>(), v = read<int>();
    adde(u, v), adde(v, u);
  }
  dfs(1, 0);
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = 1LL * fac[i - 1] * i % mod;
  ifac[n] = qpow(fac[n], mod - 2);
  for (int i = n - 1; i >= 1; i--)
    ifac[i] = 1LL * ifac[i + 1] * (i + 1) % mod;

  //	for(int i=1;i<=n;i++) cout<<num[i]<<" ";cout<<endl;
  for (int i = 1; i <= n; i++)
    g[n - i] = 1LL * num[i] * fac[i] % mod;
  for (int i = 0; i <= n; i++)
    f[i] = ifac[i];
  prepare(n + 1 + n + 1 - 1), NTT(f, 1), NTT(g, 1);
  for (int i = 0; i < limit; i++)
    f[i] = 1LL * f[i] * g[i] % mod;
  NTT(f, -1);

  for (int k = 1; k <= n; k++) {
    int ret = 1LL * n * C(n, k) % mod;
    ret = sub(ret, 1LL * ifac[k] * f[n - k] % mod);
    printf("%d\n", ret);
  }
  return 0;
}
} // namespace run
int main() {
#ifdef my
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
#endif
  return run::main();
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline T read() {
  T f = 0, x = 0;
  char c = getchar();
  while (!isdigit(c))
    f = c == '-', c = getchar();
  while (isdigit(c))
    x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 6e5 + 9, mod = 924844033;
inline int add(int x, int y) { return x + y >= mod ? x - mod + y : x + y; }
inline int sub(int x, int y) { return x >= y ? x - y : x + mod - y; }
inline int qpow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1)
      ret = 1LL * x * ret % mod;
    x = 1LL * x * x % mod, y >>= 1;
  }
  return ret;
}

int rev[N], limit, bit, Gi = qpow(5, mod - 2);
inline void prepare(int len) {
  limit = 1, bit = 0;
  while (limit < len)
    limit <<= 1, bit++;
  for (int i = 1; i < limit; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bit - 1));
}
inline void NTT(int *a, int inv) {
  for (int i = 1; i < limit; i++)
    if (i < rev[i])
      swap(a[i], a[rev[i]]);
  for (int mid = 1; mid < limit; mid <<= 1) {
    int tmp = qpow(~inv ? 5 : Gi, (mod - 1) / (mid << 1));
    for (int i = 0, R = mid << 1; i < limit; i += R)
      for (int j = 0, omega = 1; j < mid;
           j++, omega = 1LL * omega * tmp % mod) {
        int x = a[i + j], y = 1LL * omega * a[i + j + mid] % mod;
        a[i + j] = add(x, y), a[i + j + mid] = sub(x, y);
      }
  }
  if (inv == -1) {
    inv = qpow(limit, mod - 2);
    for (int i = 0; i < limit; i++)
      a[i] = 1LL * a[i] * inv % mod;
  }
}

int head[N], nex[N], to[N], cnt;
inline void adde(int u, int v) {
  nex[++cnt] = head[u];
  head[u] = cnt, to[cnt] = v;
}
int g[N], f[N], n, siz[N], num[N], fac[N], ifac[N];
inline void dfs(int u, int _f) {
  siz[u] = 1;
  for (int i = head[u]; i; i = nex[i])
    if (to[i] ^ _f)
      dfs(to[i], u), siz[u] += siz[to[i]], num[siz[to[i]]]++;
  num[n - siz[u]]++;
}

inline int C(int _n, int _m) {
  if (_n < 0 || _m < 0 || _n < _m)
    return 0;
  return 1LL * fac[_n] * ifac[_m] % mod * ifac[_n - _m] % mod;
}

int main() {
  n = read<int>();
  for (int i = 1; i < n; i++) {
    int u = read<int>(), v = read<int>();
    adde(u, v), adde(v, u);
  }
  dfs(1, 0);
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = 1LL * fac[i - 1] * i % mod;
  ifac[n] = qpow(fac[n], mod - 2);
  for (int i = n - 1; i >= 1; i--)
    ifac[i] = 1LL * ifac[i + 1] * (i + 1) % mod;

  //	for(int i=1;i<=n;i++) cout<<num[i]<<" ";cout<<endl;
  for (int i = 1; i <= n; i++)
    g[n - i] = 1LL * num[i] * fac[i] % mod;
  for (int i = 0; i <= n; i++)
    f[i] = ifac[i];
  prepare(n + 1 + n + 1 - 1), NTT(f, 1), NTT(g, 1);
  for (int i = 0; i < limit; i++)
    f[i] = 1LL * f[i] * g[i] % mod;
  NTT(f, -1);

  for (int k = 1; k <= n; k++) {
    int ret = 1LL * n * C(n, k) % mod;
    ret = sub(ret, 1LL * ifac[k] * f[n - k] % mod);
    printf("%d\n", ret);
  }
  return 0;
}
} // namespace run
int main() {
#ifdef my
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
#endif
  return run::main();
}