Problem p03991 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
using namespace std;
const int maxn = 200005, maxe = maxn << 1, TT = 924844033;
int n, L, len, sz[maxn], rev[maxn];
int e, lnk[maxn], nxt[maxe], son[maxe];
long long fct[maxn], ifct[maxn], G[2][maxn], a[maxn], b[maxn], c[maxn];
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int ret = 0;
  bool f = 0;
  char ch = nc();
  while (ch > '9' || ch < '0')
    f ^= ch == '-', ch = nc();
  while (ch <= '9' && ch >= '0')
    ret = ret * 10 + ch - '0', ch = nc();
  return f ? -ret : ret;
}
inline void add_e(int x, int y) {
  son[++e] = y;
  nxt[e] = lnk[x];
  lnk[x] = e;
}
void DFS(int x, int fa) {
  sz[x] = 1;
  for (int i = lnk[x]; i; i = nxt[i])
    if (son[i] ^ fa)
      DFS(son[i], x), sz[x] += sz[son[i]], a[sz[son[i]]]--;
  if (~fa)
    a[n - sz[x]]--;
  a[n]++;
}
inline long long pw(long long x, long long y) {
  long long ret = 1, w = x % TT;
  while (1) {
    if (y & 1)
      ret = ret * w % TT;
    if (!(y >>= 1))
      return ret;
    w = w * w % TT;
  }
}
inline void rsv(long long *A) {
  for (int i = 0; i < n - i; i++)
    swap(A[i], A[n - i]);
}
inline void NTT(long long *A, bool flg) {
  for (int i = 0; i < len; i++)
    if (i < rev[i])
      swap(A[i], A[rev[i]]);
  for (int i = 1; (i << 1) <= len; i <<= 1)
    for (int j = 0; j < len; j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long x = A[j | k], y = A[i | j | k] * G[flg][i | k] % TT;
        A[i | j | k] = x < y ? x - y + TT : x - y;
        A[j | k] = x + y >= TT ? x + y - TT : x + y;
      }
  if (flg) {
    int inv = pw(len, TT - 2);
    for (int i = 0; i < len; i++)
      A[i] = A[i] * inv % TT;
  }
}
int main() {
  n = read();
  for (int i = fct[0] = 1; i <= n; i++)
    fct[i] = fct[i - 1] * i % TT;
  ifct[n] = pw(fct[n], TT - 2);
  for (int i = n; i; i--)
    ifct[i - 1] = ifct[i] * i % TT;
  for (L = 0, len = 1; len <= (n << 1); L++, len <<= 1)
    ;
  for (int i = 1; i < len; i++)
    rev[i] = rev[i >> 1] >> 1 | (i & 1) * (len >> 1);
  G[0][0] = 5, G[1][0] = pw(5, TT - 2);
  for (int T = 0; T < 2; T++)
    for (int i = 1; i < len; i <<= 1) {
      G[T][i] = 1;
      long long now = pw(G[T][0], (TT - 1 >> 1) / i);
      for (int j = 1; j < i; j++)
        G[T][i | j] = G[T][i | j - 1] * now % TT;
    }
  for (int i = 1, x, y; i < n; i++)
    x = read(), y = read(), add_e(x, y), add_e(y, x);
  DFS(1, -1);
  for (int i = 1; i <= n; i++)
    a[i] = (a[i] + TT) * fct[i] % TT;
  for (int i = 0; i < n; i++)
    b[i] = ifct[i];
  rsv(a);
  NTT(a, 0), NTT(b, 0);
  for (int i = 0; i < len; i++)
    c[i] = a[i] * b[i] % TT;
  NTT(c, 1);
  rsv(c);
  for (int i = 1; i <= n; i++)
    printf("%lld\n", c[i] * ifct[i] % TT);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
using namespace std;
const int maxn = 600005, maxe = maxn << 1, TT = 924844033;
int n, L, len, sz[maxn], rev[maxn];
int e, lnk[maxn], nxt[maxe], son[maxe];
long long fct[maxn], ifct[maxn], G[2][maxn], a[maxn], b[maxn], c[maxn];
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int ret = 0;
  bool f = 0;
  char ch = nc();
  while (ch > '9' || ch < '0')
    f ^= ch == '-', ch = nc();
  while (ch <= '9' && ch >= '0')
    ret = ret * 10 + ch - '0', ch = nc();
  return f ? -ret : ret;
}
inline void add_e(int x, int y) {
  son[++e] = y;
  nxt[e] = lnk[x];
  lnk[x] = e;
}
void DFS(int x, int fa) {
  sz[x] = 1;
  for (int i = lnk[x]; i; i = nxt[i])
    if (son[i] ^ fa)
      DFS(son[i], x), sz[x] += sz[son[i]], a[sz[son[i]]]--;
  if (~fa)
    a[n - sz[x]]--;
  a[n]++;
}
inline long long pw(long long x, long long y) {
  long long ret = 1, w = x % TT;
  while (1) {
    if (y & 1)
      ret = ret * w % TT;
    if (!(y >>= 1))
      return ret;
    w = w * w % TT;
  }
}
inline void rsv(long long *A) {
  for (int i = 0; i < n - i; i++)
    swap(A[i], A[n - i]);
}
inline void NTT(long long *A, bool flg) {
  for (int i = 0; i < len; i++)
    if (i < rev[i])
      swap(A[i], A[rev[i]]);
  for (int i = 1; (i << 1) <= len; i <<= 1)
    for (int j = 0; j < len; j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long x = A[j | k], y = A[i | j | k] * G[flg][i | k] % TT;
        A[i | j | k] = x < y ? x - y + TT : x - y;
        A[j | k] = x + y >= TT ? x + y - TT : x + y;
      }
  if (flg) {
    int inv = pw(len, TT - 2);
    for (int i = 0; i < len; i++)
      A[i] = A[i] * inv % TT;
  }
}
int main() {
  n = read();
  for (int i = fct[0] = 1; i <= n; i++)
    fct[i] = fct[i - 1] * i % TT;
  ifct[n] = pw(fct[n], TT - 2);
  for (int i = n; i; i--)
    ifct[i - 1] = ifct[i] * i % TT;
  for (L = 0, len = 1; len <= (n << 1); L++, len <<= 1)
    ;
  for (int i = 1; i < len; i++)
    rev[i] = rev[i >> 1] >> 1 | (i & 1) * (len >> 1);
  G[0][0] = 5, G[1][0] = pw(5, TT - 2);
  for (int T = 0; T < 2; T++)
    for (int i = 1; i < len; i <<= 1) {
      G[T][i] = 1;
      long long now = pw(G[T][0], (TT - 1 >> 1) / i);
      for (int j = 1; j < i; j++)
        G[T][i | j] = G[T][i | j - 1] * now % TT;
    }
  for (int i = 1, x, y; i < n; i++)
    x = read(), y = read(), add_e(x, y), add_e(y, x);
  DFS(1, -1);
  for (int i = 1; i <= n; i++)
    a[i] = (a[i] + TT) * fct[i] % TT;
  for (int i = 0; i < n; i++)
    b[i] = ifct[i];
  rsv(a);
  NTT(a, 0), NTT(b, 0);
  for (int i = 0; i < len; i++)
    c[i] = a[i] * b[i] % TT;
  NTT(c, 1);
  rsv(c);
  for (int i = 1; i <= n; i++)
    printf("%lld\n", c[i] * ifct[i] % TT);
  return 0;
}