Complex operator*(const Complex &b) const { return Complex(x * b.x - y * b.y, x * b.y + y * b.x); } }; int rev[N]; voidFFT(Complex *A, int n, int inv) { for (int i = 0; i < n; i++) if (i < rev[i]) swap(A[i], A[rev[i]]); for (int l = 1; l < n; l <<= 1) { Complex temp(cos(pi / l), inv * sin(pi / l)); for (int i = 0; i < n; i += (l << 1)) { Complex omega(1, 0); for (int j = 0; j < l; j++, omega = omega * temp) { Complex x = A[i + j], y = omega * A[i + j + l]; A[i + j] = x + y; A[i + j + l] = x - y; } } }
if (inv == -1) for (int i = 0; i < n; i++) A[i].x = ll(A[i].x / n + 0.5); }
voidFFTX(Complex *a, int n, Complex *b, int m, Complex *ans) { int ML = 1, bit = 0; while (ML < n + m) ML <<= 1, bit++; for (int i = 0; i < ML; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bit - 1)); FFT(a, ML, 1); FFT(b, ML, 1); for (int i = 0; i < ML; i++) ans[i] = a[i] * b[i]; FFT(ans, ML, -1); } int a[N]; ll ans[N]; Complex f[N], g[N], c[N]; intmain() { int n = read(), x = read(); for (int i = 1; i <= n; i++) { int u = read(); a[i] = a[i - 1] + (u < x); } for (int i = 0; i <= n; i++) { if (i != n) f[a[i]].x++; if (i) g[a[i]].x++; }
reverse(g, g + n + 1); FFTX(f, n, g, n, c); for (int k = 0; k <= n; k++) ans[k] = ll(c[n - k].x); ans[0] = 1ll * n * (n + 1) / 2; for (int k = 1; k <= n; k++) ans[0] -= ans[k]; for (int k = 0; k <= n; k++) printf("%lld ", ans[k]); }