QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184686#6324. Expanded Hullhos_lyricAC ✓107ms4752kbC++1412.1kb2023-09-21 05:09:112023-09-21 05:09:11

Judging History

你现在查看的是最新测评结果

  • [2023-09-21 05:09:11]
  • 评测
  • 测评结果:AC
  • 用时:107ms
  • 内存:4752kb
  • [2023-09-21 05:09:11]
  • 提交

answer

#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


////////////////////////////////////////////////////////////////////////////////
template <unsigned M_> struct ModInt {
  static constexpr unsigned M = M_;
  unsigned x;
  constexpr ModInt() : x(0U) {}
  constexpr ModInt(unsigned x_) : x(x_ % M) {}
  constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
  constexpr ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
  constexpr ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModInt &operator*=(const ModInt &a) { x = (static_cast<unsigned long long>(x) * a.x) % M; return *this; }
  ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
  ModInt pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModInt inv() const {
    unsigned a = M, b = x; int y = 0, z = 1;
    for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
    assert(a == 1U); return ModInt(y);
  }
  ModInt operator+() const { return *this; }
  ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
  ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
  ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
  ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
  ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
  template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
  template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
  template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
  template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModInt &a) const { return (x == a.x); }
  bool operator!=(const ModInt &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
////////////////////////////////////////////////////////////////////////////////

constexpr unsigned MO = 998244353;
using Mint = ModInt<MO>;

constexpr int LIM_INV = 1010;
Mint inv[LIM_INV], fac[LIM_INV], invFac[LIM_INV];

void prepare() {
  inv[1] = 1;
  for (int i = 2; i < LIM_INV; ++i) {
    inv[i] = -((Mint::M / i) * inv[Mint::M % i]);
  }
  fac[0] = invFac[0] = 1;
  for (int i = 1; i < LIM_INV; ++i) {
    fac[i] = fac[i - 1] * i;
    invFac[i] = invFac[i - 1] * inv[i];
  }
}
Mint binom(Int n, Int k) {
  if (n < 0) {
    if (k >= 0) {
      return ((k & 1) ? -1 : +1) * binom(-n + k - 1, k);
    } else if (n - k >= 0) {
      return (((n - k) & 1) ? -1 : +1) * binom(-k - 1, n - k);
    } else {
      return 0;
    }
  } else {
    if (0 <= k && k <= n) {
      assert(n < LIM_INV);
      return fac[n] * invFac[k] * invFac[n - k];
    } else {
      return 0;
    }
  }
}


Mint interpolateIota(const vector<Mint> &fs, long long n) {
  const int fsLen = fs.size();
  vector<Mint> prodR(fsLen + 1);
  prodR[fsLen] = 1;
  for (int i = fsLen; --i >= 0; ) prodR[i] = (n - i) * prodR[i + 1];
  Mint ans = 0;
  Mint prodL = 1;
  for (int i = 0; i < fsLen; ++i) {
    // (i - 0) ... (i - (i - 1)) (i - (i + 1)) ... (i - (fsLen - 1))
    ans += invFac[i] * (((fsLen - 1 - i) & 1) ? -1 : +1) *
           invFac[fsLen - 1 - i] * fs[i] * prodL * prodR[i + 1];
    prodL *= (n - i);
  }
  return ans;
}


inline long long div53(long long a, int b) {
  return static_cast<double>(a) / b;
}
inline long long div53(long long a, long long b) {
  return static_cast<double>(a) / b;
}


using Double = long double;

struct PT {
	Double x, y, z;
	PT() {}
	PT(Double x, Double y, Double z) : x(x), y(y), z(z) {}
	PT operator+(const PT &a) const { return PT(x + a.x, y + a.y, z + a.z); }
	PT operator-(const PT &a) const { return PT(x - a.x, y - a.y, z - a.z); }
	PT operator+() const { return PT(+x, +y, +z); }
	PT operator-() const { return PT(-x, -y, -z); }
	PT operator*(const Double &k) const { return PT(x * k, y * k, z * k); }
	PT operator/(const Double &k) const { return PT(x / k, y / k, z / k); }
	friend PT operator*(const Double &k, const PT &a) { return PT(k * a.x, k * a.y, k * a.z); }
	PT &operator+=(const PT &a) { x += a.x; y += a.y; z += a.z; return *this; }
	PT &operator-=(const PT &a) { x -= a.x; y -= a.y; z -= a.z; return *this; }
	PT &operator*=(const Double &k) { x *= k; y *= k; z *= k; return *this; }
	PT &operator/=(const Double &k) { x /= k; y /= k; z /= k; return *this; }
	Double abs() const { return sqrt(x * x + y * y + z * z); }
	Double abs2() const { return x * x + y * y + z * z; }
	Double dot(const PT &a) const { return x * a.x + y * a.y + z * a.z; }
	PT cross(const PT a) const { return PT(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x); }
	friend ostream &operator<<(ostream &os, const PT &a) { os << "(" << a.x << ", " << a.y << ", " << a.z << ")"; return os; }
};
const Double EPS = 1e-10;
const Double INF = 1e+10;
const Double PI = acos(-1.0L);
int sig(Double r) { return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0; }
PT tri(const PT &a, const PT &b, const PT &c) { return (b - a).cross(c - a); }
Double tet(const PT &a, const PT &b, const PT &c, const PT &d) { return (b - a).cross(c - a).dot(d - a); }


//	Convex Hull
//	No 4 Points Planar!!!
//	Output: [N][0 .. lens[N]]
//********************//
const int LIM_N = 210;
int N;
PT P[LIM_N + 1];
int lens[LIM_N + 1], as[LIM_N + 1][LIM_N * 2], bs[LIM_N + 1][LIM_N * 2], cs[LIM_N + 1][LIM_N * 2], ss[LIM_N + 1][LIM_N * 2];
//********************//
void convexHull3D() {
	fill(lens, lens + N + 1, 0);
	lens[3] = 2;
	as[3][0] = 0; bs[3][0] = 1; cs[3][0] = 2;
	as[3][1] = 0; bs[3][1] = 2; cs[3][1] = 1;
	for (int i = 3; i < N; ++i) {
		for (int j = 0; j < lens[i]; ++j) {
			const int a = as[i][j], b = bs[i][j], c = cs[i][j];
			ss[a][b] = ss[b][c] = ss[c][a] = (tet(P[a], P[b], P[c], P[i]) < 0);
		}
		for (int j = 0; j < lens[i]; ++j) {
			const int a = as[i][j], b = bs[i][j], c = cs[i][j];
			if (ss[a][b]) {
				as[i + 1][lens[i + 1]] = a; bs[i + 1][lens[i + 1]] = b; cs[i + 1][lens[i + 1]] = c; ++lens[i + 1];
			} else {
				if (ss[b][a]) { as[i + 1][lens[i + 1]] = i; bs[i + 1][lens[i + 1]] = a; cs[i + 1][lens[i + 1]] = b; ++lens[i + 1]; }
				if (ss[c][b]) { as[i + 1][lens[i + 1]] = i; bs[i + 1][lens[i + 1]] = b; cs[i + 1][lens[i + 1]] = c; ++lens[i + 1]; }
				if (ss[a][c]) { as[i + 1][lens[i + 1]] = i; bs[i + 1][lens[i + 1]] = c; cs[i + 1][lens[i + 1]] = a; ++lens[i + 1]; }
			}
		}
	}
}
//********************//


Int det3(
    Int a00, Int a01, Int a02,
    Int a10, Int a11, Int a12,
    Int a20, Int a21, Int a22) {
  Int ret = 0;
  ret += a00 * (a11 * a22 - a12 * a21);
  ret += a10 * (a21 * a02 - a22 * a01);
  ret += a20 * (a01 * a12 - a02 * a11);
  return ret;
}


Int K;
vector<Int> X, Y, Z;

// a x + b y + c z <= d
int LEN;
vector<Int> A, B, C;
vector<Int> D;

int main() {
  prepare();
  
  for (; ~scanf("%d%lld", &N, &K); ) {
    X.resize(N);
    Y.resize(N);
    Z.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%lld%lld%lld", &X[i], &Y[i], &Z[i]);
    }
    
    const Int minX = *min_element(X.begin(), X.end()), maxX = *max_element(X.begin(), X.end());
    const Int minY = *min_element(Y.begin(), Y.end()), maxY = *max_element(Y.begin(), Y.end());
    const Int minZ = *min_element(Z.begin(), Z.end()), maxZ = *max_element(Z.begin(), Z.end());
// cerr<<"["<<minX<<", "<<maxX<<"] ["<<minY<<", "<<maxY<<"] ["<<minZ<<", "<<maxZ<<"]"<<endl;
    
    for (int i = 0; i < N; ++i) {
      const Double theta = tan((Double)(i * i + 1));
      const Double phi = tan((Double)(i * i + 2));
      P[i] = PT(X[i], Y[i], Z[i]) + 1e-4L * PT(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
    }
    convexHull3D();
    LEN = lens[N];
    A.resize(LEN);
    B.resize(LEN);
    C.resize(LEN);
    D.resize(LEN);
    Int vol = 0;
    for (int h = 0; h < LEN; ++h) {
      const int i = as[N][h];
      const int j = bs[N][h];
      const int k = cs[N][h];
// cerr<<i<<" "<<j<<" "<<k<<endl;
      A[h] = det3(
        Y[i], Z[i], 1,
        Y[j], Z[j], 1,
        Y[k], Z[k], 1
      );
      B[h] = det3(
        Z[i], X[i], 1,
        Z[j], X[j], 1,
        Z[k], X[k], 1
      );
      C[h] = det3(
        X[i], Y[i], 1,
        X[j], Y[j], 1,
        X[k], Y[k], 1
      );
      D[h] = det3(
        X[i], Y[i], Z[i],
        X[j], Y[j], Z[j],
        X[k], Y[k], Z[k]
      );
      vol += D[h];
    }
// cerr<<"A = "<<A<<endl;
// cerr<<"B = "<<B<<endl;
// cerr<<"C = "<<C<<endl;
// cerr<<"D = "<<D<<endl;
    
    // yusushite
    Int plus = 0, minus = 0;
    for (Int x = minX; x <= maxX; ++x) for (Int y = minY; y <= maxY; ++y) {
      Int plusL = minZ, plusU = maxZ;
      Int minusL = minZ, minusU = maxZ;
      for (int h = 0; h < LEN; ++h) if (!(A[h] == 0 && B[h] == 0 && C[h] == 0 && D[h] == 0)) {
        // c z <= d
        Int c = C[h];
        Int d = D[h] - A[h] * x - B[h] * y;
        if (c > 0) {
          // Int q = d / c;
          Int q = div53(d, c);
          Int r = d - c * q;
          if (r < 0) {
            q -= 1;
            r += c;
          }
          chmin(plusU, q);
          chmin(minusU, r ? q : (q - 1));
        } else if (c < 0) {
          c = -c;
          d = -d;
          // c z >= d
          // Int q = d / c;
          Int q = div53(d, c);
          Int r = d - c * q;
          if (r < 0) {
            q -= 1;
            r += c;
          }
          chmax(plusL, r ? (q + 1) : q);
          chmax(minusL, q + 1);
        } else {
          if (0 < d) {
            //
          } else if (0 <= d) {
// if(x==-1999&&y==-1999)cerr<<"HELP "<<A[h]<<" "<<B[h]<<" "<<C[h]<<" "<<D[h]<<endl;
            minusL = maxZ + 1;
            minusU = minZ - 1;
          } else {
            goto failed;
          }
        }
      }
      if (plusL <= plusU) {
// cerr<<x<<" "<<y<<": ["<<plusL<<", "<<plusU<<"] ["<<minusL<<", "<<minusU<<"]"<<endl;
        plus += (plusU - plusL + 1);
      }
      if (minusL <= minusU) {
        minus += (minusU - minusL + 1);
      }
     failed:{}
    }
cerr<<"vol = "<<vol<<", plus = "<<plus<<", minus = "<<minus<<endl;
    
    const Mint res = interpolateIota({
      Mint(-minus) + Mint(vol) / 6,
      Mint(1),
      Mint(plus) - Mint(vol) / 6,
    }, K + 1);
    const Mint ans = res + Mint(vol) / 6 * Mint(K).pow(3);
    printf("%u\n", ans.x);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

input:

4 2
0 0 0
1 0 0
0 1 0
0 0 1

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

4 10000
0 0 0
1 0 0
0 1 0
0 0 1

output:

59878050

result:

ok 1 number(s): "59878050"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

8 314159265358979
5 -3 -3
-5 -3 -3
0 5 -3
0 0 10
4 2 6
-4 2 6
0 -5 6
0 0 -5

output:

152811018

result:

ok 1 number(s): "152811018"

Test #4:

score: 0
Accepted
time: 1ms
memory: 4460kb

input:

100 1
0 0 77
0 0 -195
0 0 -194
0 0 -112
0 0 -192
0 0 62
0 0 73
0 0 188
0 0 -150
0 0 -26
0 0 -164
0 0 -142
0 0 -90
200 1 0
0 0 50
0 0 111
0 0 -133
0 0 91
0 0 -70
0 0 46
0 0 175
-200 -67 0
0 0 128
0 0 170
0 0 76
0 0 -28
0 0 47
0 0 -196
0 0 45
0 0 -136
0 0 96
0 0 24
0 0 -29
0 0 -141
0 0 -84
0 0 -99
0 0...

output:

882531

result:

ok 1 number(s): "882531"

Test #5:

score: 0
Accepted
time: 6ms
memory: 4368kb

input:

82 333333333
98 99 168
-106 -105 -172
113 114 193
-13 -12 -17
-115 -114 -187
71 72 123
-70 -69 -112
95 96 163
-85 -84 -137
-28 -27 -42
-31 -30 -47
-200 -67 0
-121 -120 -197
-52 -51 -82
-112 -111 -182
110 111 188
44 45 78
86 87 148
104 105 178
-73 -72 -117
47 48 83
62 63 108
-103 -102 -167
56 57 98
1...

output:

767480931

result:

ok 1 number(s): "767480931"

Test #6:

score: 0
Accepted
time: 14ms
memory: 4436kb

input:

100 1
-63 -39 51
-36 -104 70
9 -77 34
115 -153 19
-161 141 10
157 -149 -4
-82 -92 87
14 114 -64
-176 -68 122
-7 -179 93
-182 200 -9
173 97 -135
0 -1 200
-83 -189 136
117 69 -93
-3 -113 58
183 -179 -2
-52 -184 118
-107 89 9
-24 -48 36
-111 87 12
-143 -173 158
-176 -78 127
-96 162 -33
147 -111 -18
-92...

output:

9771107

result:

ok 1 number(s): "9771107"

Test #7:

score: 0
Accepted
time: 6ms
memory: 4648kb

input:

100 1159111449
82 82 90
181 181 -85
70 70 -20
1 1 0
190 190 56
-83 -83 40
-89 -89 39
136 136 146
-195 -195 47
50 50 -99
-101 -101 -161
162 162 146
23 23 152
181 181 -91
-73 -73 -5
-105 -105 6
155 155 -136
152 152 -190
-33 -33 -137
55 55 41
3 3 -199
-168 -168 -177
-111 -111 115
171 171 8
131 131 123
...

output:

681451260

result:

ok 1 number(s): "681451260"

Test #8:

score: 0
Accepted
time: 4ms
memory: 3924kb

input:

8 1
200 200 200
-200 -200 -200
200 -200 -200
-200 200 200
-200 200 -200
200 200 -200
200 -200 200
-200 -200 200

output:

64481201

result:

ok 1 number(s): "64481201"

Test #9:

score: 0
Accepted
time: 4ms
memory: 4140kb

input:

8 10
200 200 200
-200 200 200
-200 -200 200
200 200 -200
-200 -200 -200
200 -200 -200
-200 200 -200
200 -200 200

output:

160373409

result:

ok 1 number(s): "160373409"

Test #10:

score: 0
Accepted
time: 2ms
memory: 3820kb

input:

8 1234567890123
-200 -200 200
-200 200 200
-200 200 -200
-200 -200 -200
200 -200 200
200 -200 -200
200 200 200
200 200 -200

output:

868669244

result:

ok 1 number(s): "868669244"

Test #11:

score: 0
Accepted
time: 14ms
memory: 3924kb

input:

24 1
200 200 140
200 -140 200
140 200 -200
-140 -200 200
-200 200 140
-200 200 -140
-200 140 200
200 140 -200
200 -140 -200
200 200 -140
-200 -200 140
-200 -140 -200
-200 -200 -140
-200 140 -200
-140 200 200
140 -200 200
200 -200 -140
-200 -140 200
200 140 200
200 -200 140
140 -200 -200
140 200 200
...

output:

64178641

result:

ok 1 number(s): "64178641"

Test #12:

score: 0
Accepted
time: 14ms
memory: 4188kb

input:

24 10
-200 140 -200
200 -140 200
200 140 200
-200 -140 -200
140 -200 -200
200 200 140
-200 -200 -140
-200 200 140
200 -140 -200
-200 -200 140
-140 200 -200
140 -200 200
200 -200 -140
-200 -140 200
-140 -200 -200
-200 200 -140
200 -200 140
200 200 -140
140 200 -200
-140 200 200
-140 -200 200
200 140 ...

output:

869176162

result:

ok 1 number(s): "869176162"

Test #13:

score: 0
Accepted
time: 14ms
memory: 4240kb

input:

24 1234567890123
-200 -140 -200
140 -200 -200
140 200 -200
200 -140 200
-200 -140 200
200 140 200
-140 200 -200
-200 -200 -140
200 200 140
-200 140 -200
-140 200 200
-140 -200 -200
200 -200 140
-200 -200 140
200 -140 -200
140 -200 200
200 140 -200
200 200 -140
200 -200 -140
-140 -200 200
-200 140 20...

output:

908630290

result:

ok 1 number(s): "908630290"

Test #14:

score: 0
Accepted
time: 77ms
memory: 4752kb

input:

100 1
11 200 0
-197 36 0
-199 17 0
-76 -185 0
136 -147 0
-194 -50 0
140 143 0
0 0 -200
-5 200 0
-180 -88 0
-21 199 0
-99 -174 0
-186 74 0
116 -163 0
153 128 0
118 -161 0
-68 188 0
-200 -1 0
-194 47 0
-196 -40 0
-185 76 0
196 41 0
146 137 0
99 174 0
-124 -157 0
121 -159 0
-200 9 0
-59 191 0
-83 182 0...

output:

16722291

result:

ok 1 number(s): "16722291"

Test #15:

score: 0
Accepted
time: 75ms
memory: 4724kb

input:

100 3
-87 180 0
-163 116 0
-185 -76 0
-200 0 0
200 13 0
189 66 0
-128 -153 0
-192 57 0
44 195 0
167 110 0
-116 -163 0
47 194 0
-86 -181 0
92 -178 0
-53 -193 0
66 189 0
-92 -178 0
-176 96 0
191 -60 0
197 32 0
-78 -184 0
-14 -200 0
-179 -89 0
109 168 0
177 -94 0
176 -95 0
94 -176 0
70 187 0
128 153 0
...

output:

450766066

result:

ok 1 number(s): "450766066"

Test #16:

score: 0
Accepted
time: 76ms
memory: 4388kb

input:

100 784433716
-103 172 0
-154 128 0
129 -153 0
84 -181 0
-7 200 0
138 -145 0
-97 -175 0
196 -38 0
-148 -135 0
-197 -37 0
141 142 0
128 -154 0
-164 114 0
106 -169 0
-151 131 0
-122 -158 0
170 105 0
61 -191 0
-192 -58 0
197 -33 0
-170 -105 0
109 -167 0
-181 85 0
166 111 0
-44 -195 0
0 0 -200
49 -194 0...

output:

631042395

result:

ok 1 number(s): "631042395"

Test #17:

score: 0
Accepted
time: 9ms
memory: 3896kb

input:

20 1
94 -145 -152
38 -114 138
186 -113 -75
154 -91 -178
191 173 -24
174 23 -128
126 -60 -17
-5 182 -3
-20 -71 157
197 51 68
41 117 -190
184 32 -152
21 -112 158
-14 110 172
24 -9 31
-13 -93 -192
-108 104 179
17 86 -76
107 -72 53
99 -19 60

output:

16547736

result:

ok 1 number(s): "16547736"

Test #18:

score: 0
Accepted
time: 31ms
memory: 4608kb

input:

93 1
-64 -152 107
92 128 -174
170 56 177
137 -113 -41
-37 -24 -185
185 162 -187
182 35 79
-71 73 -114
126 -117 -44
-160 121 103
-98 163 59
141 77 130
-96 -114 45
130 152 -190
164 -71 188
-65 2 -86
80 16 -24
-104 -118 -131
123 -165 -195
118 26 164
-169 145 1
-147 -129 -106
-137 -85 -192
107 182 111
-...

output:

41981036

result:

ok 1 number(s): "41981036"

Test #19:

score: 0
Accepted
time: 23ms
memory: 4168kb

input:

62 1
-8 164 -123
-146 11 -34
176 151 -132
-26 -81 39
71 174 -83
-111 29 90
85 153 28
156 -174 0
144 -115 -124
-96 -31 -65
162 128 -118
-9 152 -149
-191 -87 -107
-161 84 200
181 -4 -59
-116 -70 71
-68 -141 108
4 -2 -13
96 155 -188
8 144 -39
-90 -20 -66
-69 -197 -156
136 -36 -14
13 -150 -82
71 91 -119...

output:

30784242

result:

ok 1 number(s): "30784242"

Test #20:

score: 0
Accepted
time: 17ms
memory: 4064kb

input:

45 1
104 177 -54
112 168 192
3 -135 51
-149 35 -105
156 -97 25
161 22 -106
113 -120 -75
71 144 144
-188 -36 110
137 63 -137
43 -81 169
183 184 178
-65 183 -148
185 -15 -196
-164 -154 10
67 -178 188
-81 17 -126
164 97 -87
157 156 104
19 33 146
172 169 121
33 146 -141
166 -20 9
158 116 163
-144 -177 -...

output:

34262460

result:

ok 1 number(s): "34262460"

Test #21:

score: 0
Accepted
time: 12ms
memory: 4188kb

input:

26 1
-19 77 -129
71 57 106
-30 35 54
68 86 109
107 -88 -14
-159 149 178
-39 161 88
-176 -24 -15
171 -89 -90
97 -88 69
188 9 -14
-184 65 -176
77 -145 -98
-5 14 -99
94 158 -192
93 138 175
-142 -68 -29
66 -14 -49
196 130 -14
-40 -13 138
169 41 54
149 46 -122
-3 -156 140
-4 17 26
-90 106 146
-107 -114 26

output:

22630372

result:

ok 1 number(s): "22630372"

Test #22:

score: 0
Accepted
time: 28ms
memory: 4556kb

input:

83 1
150 77 20
-184 -196 23
-128 189 119
194 177 110
-125 -76 -165
11 165 -108
-34 28 100
78 30 23
83 -60 61
20 -15 101
-199 43 -23
95 -18 197
45 -150 104
-53 -10 -53
184 101 -11
-15 125 136
127 -180 29
-14 -33 -150
-73 15 -97
123 62 25
-110 44 -75
99 -58 -32
-57 -85 95
91 -90 12
105 -11 106
172 -18...

output:

44429135

result:

ok 1 number(s): "44429135"

Test #23:

score: 0
Accepted
time: 18ms
memory: 4264kb

input:

37 1
86 -96 195
-92 -11 -166
40 -58 145
-132 -123 64
-196 39 -52
-199 36 -59
41 119 171
131 170 146
-70 12 160
-48 193 -152
57 33 97
-75 -48 -104
-17 36 170
-20 133 9
171 100 44
119 110 -105
-44 -111 -172
43 154 -96
181 80 157
-180 98 -103
-90 -130 -110
-84 173 41
189 -139 55
-144 107 -142
-114 -179...

output:

28728439

result:

ok 1 number(s): "28728439"

Test #24:

score: 0
Accepted
time: 27ms
memory: 4168kb

input:

58 1
-45 174 -64
128 -186 -75
-82 -108 23
-88 -5 17
149 191 -18
122 133 150
-47 -64 100
-2 113 -82
-157 -94 55
194 -56 -61
-117 -83 109
-83 43 -26
107 -24 17
141 -35 -12
53 199 188
68 -145 113
15 -73 -188
164 -56 -171
-46 149 43
2 -153 29
25 -104 35
57 -16 60
-143 -127 -13
78 -143 42
148 -139 187
-1...

output:

37363387

result:

ok 1 number(s): "37363387"

Test #25:

score: 0
Accepted
time: 16ms
memory: 4168kb

input:

42 1
105 -190 -22
174 49 89
-42 163 -189
-61 62 81
190 134 20
-147 -43 117
-95 -104 133
-103 -19 47
159 48 -79
26 -97 -58
-192 138 -118
1 18 14
151 79 -21
-188 -135 -132
151 -164 -3
196 2 11
-62 46 98
135 -29 182
-85 102 -170
-161 -85 105
2 -49 101
-132 40 -133
73 58 79
13 -78 134
-5 -196 186
26 85 ...

output:

33396223

result:

ok 1 number(s): "33396223"

Test #26:

score: 0
Accepted
time: 20ms
memory: 4200kb

input:

50 1
-102 -104 -195
95 81 -157
-119 17 -123
16 -122 -169
147 78 152
48 80 125
-45 -150 -22
111 -85 124
14 -35 -34
-195 9 -128
197 -4 -64
24 -118 100
195 -82 102
50 -132 -104
-100 -95 142
-44 56 176
170 -177 -154
73 109 -158
-143 -184 -178
-160 -1 155
115 -143 107
-98 33 -157
190 -21 62
107 -48 -41
-...

output:

33656374

result:

ok 1 number(s): "33656374"

Test #27:

score: 0
Accepted
time: 16ms
memory: 3984kb

input:

34 1
-166 -133 -99
-128 133 0
-81 193 24
46 18 143
144 94 -167
-9 146 17
-73 52 15
116 132 14
1 -179 139
-194 169 -183
-63 191 10
-90 -50 -121
-96 -170 -197
181 149 182
-180 90 -30
194 -114 -17
-109 146 104
150 -109 -143
56 166 -142
130 123 -8
-50 178 -108
-27 -161 -107
-199 -42 139
78 22 -104
-11 -...

output:

35731863

result:

ok 1 number(s): "35731863"

Test #28:

score: 0
Accepted
time: 20ms
memory: 4144kb

input:

57 1
-93 -132 -143
-33 159 -194
-123 25 -143
-140 -85 74
69 -191 140
57 74 -179
-145 84 177
-73 -191 175
141 149 -134
-36 22 -130
-87 67 133
6 -59 -41
82 -34 -137
-10 -4 4
-194 -185 -143
-60 57 -104
-193 4 -118
-52 -179 33
-85 -87 -38
-126 -100 -79
161 161 -186
24 -126 91
152 -22 -24
-24 -32 138
-19...

output:

42104731

result:

ok 1 number(s): "42104731"

Test #29:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

5 1
25 -2 20
100 129 -140
-37 133 -181
7 -92 -114
22 116 -82

output:

951995

result:

ok 1 number(s): "951995"

Test #30:

score: 0
Accepted
time: 2ms
memory: 3804kb

input:

5 147
-64 98 50
-143 10 -118
131 -79 62
-59 138 -149
-142 -7 196

output:

884272932

result:

ok 1 number(s): "884272932"

Test #31:

score: 0
Accepted
time: 2ms
memory: 4084kb

input:

5 271828182845
60 -181 -110
-75 196 -71
55 9 -58
-74 -48 -76
91 -177 128

output:

846002797

result:

ok 1 number(s): "846002797"

Test #32:

score: 0
Accepted
time: 107ms
memory: 4476kb

input:

100 1
193 -53 0
96 -132 115
-97 154 -82
173 75 67
-44 91 173
-63 51 -183
-142 99 101
18 -199 -5
-35 181 77
-44 -63 184
-66 -123 -143
138 140 40
0 82 -182
-100 -172 20
142 139 -24
-187 1 -71
131 -145 45
114 84 -141
186 1 -74
132 -7 -150
57 102 -162
-131 -88 123
-92 31 175
162 114 25
152 -54 -119
-10 ...

output:

29842680

result:

ok 1 number(s): "29842680"

Test #33:

score: 0
Accepted
time: 107ms
memory: 4440kb

input:

100 2
-68 44 183
-15 -129 152
-132 143 48
-187 25 -65
116 -88 -138
157 46 -115
77 18 -184
24 53 191
-135 143 -36
161 -96 71
-48 178 78
-3 -59 191
133 -58 -137
-17 -1 -199
25 -197 -23
47 -91 172
6 155 -126
38 107 -164
187 69 -17
23 189 -62
111 -150 74
5 136 -147
-112 7 -166
-61 67 -178
157 -119 -33
-...

output:

237639433

result:

ok 1 number(s): "237639433"

Test #34:

score: 0
Accepted
time: 104ms
memory: 4464kb

input:

100 36
164 -35 109
-181 -61 60
141 61 -128
-117 138 86
65 -74 174
-125 72 139
-183 -60 -53
-171 6 104
144 117 74
-166 -20 -110
-159 -113 -46
-159 -90 -81
79 -65 172
-43 -95 -171
76 91 161
-178 29 86
-130 13 -151
186 26 -70
-165 -105 42
-108 5 -168
-176 -84 -43
77 -79 -167
-171 90 52
39 132 -145
-82 ...

output:

133126869

result:

ok 1 number(s): "133126869"

Test #35:

score: 0
Accepted
time: 100ms
memory: 4436kb

input:

100 899000570
-33 195 29
41 -174 89
173 -52 86
107 149 -79
-194 48 -7
179 86 26
125 -85 -130
-162 110 -41
37 -191 -47
-64 -166 93
88 88 -157
179 67 59
-146 119 -66
-89 168 -63
-73 147 -114
-146 -116 -72
-129 140 -60
160 -96 -70
-93 15 176
38 71 -183
-166 106 -37
31 110 -164
-105 106 133
83 -76 166
-...

output:

642235468

result:

ok 1 number(s): "642235468"

Test #36:

score: 0
Accepted
time: 98ms
memory: 4436kb

input:

100 527256954420915
-100 110 -134
-60 -147 -122
-18 -146 -135
-114 103 128
-38 0 196
157 106 63
79 150 -106
-8 -174 99
-196 -8 40
76 -162 89
47 152 -122
83 -102 150
-36 -79 -180
-75 120 -141
23 -196 -32
-144 114 79
-190 -61 -13
156 101 74
-133 -19 -148
-32 -89 176
-157 108 -61
162 -96 69
175 -48 83
...

output:

828026607

result:

ok 1 number(s): "828026607"

Test #37:

score: 0
Accepted
time: 38ms
memory: 4652kb

input:

100 2
-113 -117 -33
5 -174 -192
-153 23 -105
-92 178 -100
-43 -70 -94
-29 111 35
3 -164 155
-75 163 117
145 -140 102
-199 150 8
2 -63 -56
-137 -185 -56
165 -41 -88
-20 -94 -178
-47 -60 184
159 17 -148
-108 186 169
3 -51 81
-2 -45 -150
-61 -102 119
-198 -187 124
34 -179 -123
149 -132 -123
177 -147 -5...

output:

354649638

result:

ok 1 number(s): "354649638"

Test #38:

score: 0
Accepted
time: 29ms
memory: 4452kb

input:

100 5
65 -152 -103
-195 110 10
-145 -6 106
105 -20 29
-198 128 57
-89 79 -110
8 159 -6
194 132 -107
-111 88 -54
-74 -171 183
-119 -166 127
-188 33 -151
140 19 -38
-47 193 170
57 -132 16
-105 96 107
-105 -163 -15
55 -165 113
158 -111 -170
51 -92 195
185 93 110
145 149 92
47 -119 149
118 -196 65
-172 ...

output:

580842281

result:

ok 1 number(s): "580842281"

Test #39:

score: 0
Accepted
time: 27ms
memory: 4708kb

input:

100 145361171
112 53 144
61 -115 159
-148 163 22
23 -70 91
-116 -39 142
-7 -132 35
-167 162 -103
47 -169 -18
-180 -103 -116
-163 -62 70
54 79 145
76 -190 -118
10 -39 -179
69 187 78
31 139 -106
126 38 -125
-80 -101 95
151 -32 -9
-100 167 -44
-84 -82 132
59 -188 -106
45 68 165
150 26 -28
137 164 -91
-...

output:

139549314

result:

ok 1 number(s): "139549314"

Test #40:

score: 0
Accepted
time: 29ms
memory: 4400kb

input:

100 52502708246019
12 97 -77
195 163 71
160 64 110
-50 -139 99
-142 -28 -151
-91 89 -60
69 92 100
-195 31 -26
-78 -4 -110
20 12 153
148 -153 -158
144 -37 -3
188 57 164
13 -64 -39
160 177 -67
-6 -126 -189
44 -14 75
-23 96 122
133 179 -83
-161 -181 -111
156 100 -59
165 15 -29
-18 74 180
-46 126 101
63...

output:

722223460

result:

ok 1 number(s): "722223460"