/* -*- coding: utf-8 -*- * * 2520.cc: No.2520 L1 Explosion - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 1500; const int MAX_N2 = MAX_N * 2; const int MOD = 998244353; /* typedef */ using ll = long long; template struct MI { int v; MI(): v() {} MI(int _v): v(_v % MOD) { if (v < 0) v += MOD; } MI(long long _v): v(_v % MOD) { if (v < 0) v += MOD; } explicit operator int() const { return v; } MI operator+(const MI m) const { return MI(v + m.v); } MI operator-(const MI m) const { return MI(v + MOD - m.v); } MI operator*(const MI m) const { return MI((long long)v * m.v); } MI &operator+=(const MI m) { return (*this = *this + m); } MI &operator-=(const MI m) { return (*this = *this - m); } MI &operator*=(const MI m) { return (*this = *this * m); } bool operator==(const MI m) const { return v == m.v; } bool operator!=(const MI m) const { return v != m.v; } MI pow(int n) const { // a^n % MOD MI pm = 1, a = *this; while (n > 0) { if (n & 1) pm *= a; a *= a; n >>= 1; } return pm; } MI inv() const { return pow(MOD - 2); } MI operator/(const MI m) const { return *this * m.inv(); } MI &operator/=(const MI m) { return (*this = *this / m); } }; using mi = MI; /* global variables */ int xs[MAX_N], ys[MAX_N], hs[MAX_N]; ll uxs[MAX_N2], uys[MAX_N2]; int cs[MAX_N2][MAX_N2], css[MAX_N2 + 1][MAX_N2 + 1]; mi ss[MAX_N + 1]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d%d%d", xs + i, ys + i, hs + i); // let di=m-hi, // 1. (y-Yi)<=-(x-Xi)+di -> (x-Xi)+(y-Yi)<=di -> x+y<=Xi+Yi+di // 2. (y-Yi)>=-(x-Xi)-di -> (x-Xi)+(y-Yi)>=-di -> x+y>=Xi+Yi-di // 3. (y-Yi)<=(x-Xi)+di -> (x-Xi)-(y-Yi)>=-di -> x-y>=Xi-Yi-di // 4. (y-Yi)>=(x-Xi)-di -> (x-Xi)-(y-Yi)<=di -> x-y<=Xi-Yi+di int xn = 0, yn = 0; for (int i = 0; i < n; i++) { int di = m - hs[i]; uxs[xn++] = (ll)xs[i] + ys[i] - di; uxs[xn++] = (ll)xs[i] + ys[i] + di; uys[yn++] = (ll)xs[i] - ys[i] - di; uys[yn++] = (ll)xs[i] - ys[i] + di; } sort(uxs, uxs + xn); xn = unique(uxs, uxs + xn) - uxs; sort(uys, uys + yn); yn = unique(uys, uys + yn) - uys; for (int i = 0; i < n; i++) { int di = m - hs[i]; int xi0 = lower_bound(uxs, uxs + xn, (ll)xs[i] + ys[i] - di) - uxs; int xi1 = lower_bound(uxs, uxs + xn, (ll)xs[i] + ys[i] + di) - uxs; int yi0 = lower_bound(uys, uys + yn, (ll)xs[i] - ys[i] - di) - uys; int yi1 = lower_bound(uys, uys + yn, (ll)xs[i] - ys[i] + di) - uys; cs[yi0][xi0]++, cs[yi0][xi1]--; cs[yi1][xi0]--, cs[yi1][xi1]++; } for (int i = 0; i < yn; i++) for (int j = 0; j < xn; j++) { css[i + 1][j + 1] = cs[i][j] + css[i + 1][j] + css[i][j + 1] - css[i][j]; int cij = css[i + 1][j + 1]; if (cij > 0) ss[cij] += mi(uys[i + 1] - uys[i]) * (uxs[j + 1] - uxs[j]); } mi inv2 = mi(2).inv(); for (int i = 1; i <= n; i++) printf("%d\n", (int)(ss[i] * inv2)); return 0; }