結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー pekempeypekempey
提出日時 2019-12-03 00:39:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,991 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 180,736 KB
実行使用メモリ 445,340 KB
最終ジャッジ日時 2024-05-06 06:04:46
合計ジャッジ時間 70,829 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,424 ms
433,768 KB
testcase_01 AC 2,428 ms
433,768 KB
testcase_02 AC 2,425 ms
433,640 KB
testcase_03 AC 2,413 ms
433,764 KB
testcase_04 WA -
testcase_05 AC 2,426 ms
433,636 KB
testcase_06 AC 2,422 ms
433,508 KB
testcase_07 AC 2,416 ms
433,636 KB
testcase_08 AC 2,412 ms
433,632 KB
testcase_09 AC 2,417 ms
433,764 KB
testcase_10 AC 2,426 ms
433,636 KB
testcase_11 AC 2,412 ms
433,764 KB
testcase_12 AC 2,412 ms
433,636 KB
testcase_13 AC 2,390 ms
433,636 KB
testcase_14 AC 2,411 ms
433,636 KB
testcase_15 AC 2,406 ms
433,896 KB
testcase_16 AC 2,401 ms
434,916 KB
testcase_17 AC 2,450 ms
439,904 KB
testcase_18 AC 2,463 ms
441,828 KB
testcase_19 AC 2,423 ms
439,960 KB
testcase_20 AC 2,444 ms
444,168 KB
testcase_21 AC 2,412 ms
437,604 KB
testcase_22 AC 2,456 ms
442,600 KB
testcase_23 AC 2,422 ms
435,296 KB
testcase_24 AC 2,430 ms
442,724 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void initio() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};


vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(n); return n < 0 ? 0 : I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<int N>
class FFT {
  using C = complex<long double>;
  C rots[N];

public:
  FFT() {
    const long double pi = acos(-1.0L);
    for (int i = 0; i < N / 2; i++) {
      rots[i + N / 2].real(cos(2 * pi / N * i));
      rots[i + N / 2].imag(sin(2 * pi / N * i));
    }
    for (int i = N / 2 - 1; i >= 1; i--) {
      rots[i] = rots[i * 2];
    }
  }

private:
  inline static C mul(C x, C y) {
    return C(x.real() * y.real() - x.imag() * y.imag(), x.real() * y.imag() + x.imag() * y.real());
  }

  void fft(vector<C> &a, bool rev) {
    const int n = a.size();
    int i = 0;
    for (int j = 1; j < n - 1; j++) {
      for (int k = n >> 1; k > (i ^= k); k >>= 1);
      if (j < i) swap(a[i], a[j]);
    }
    for (int i = 1; i < n; i *= 2) {
      for (int j = 0; j < n; j += i * 2) {
        for (int k = 0; k < i; k++) {
          C s = a[j + k + 0];
          C t = mul(a[j + k + i], rots[i + k]);
          a[j + k + 0] = s + t;
          a[j + k + i] = s - t;
        }
      }
    }
    if (rev) {
      reverse(a.begin() + 1, a.end());
      for (int i = 0; i < n; i++) {
        a[i] *= 1.0 / n;
      }
    }
  }

public:
  vector<long long> convolution(vector<long long> a, vector<long long> b) {
    int t = 1;
    while (t < a.size() + b.size() - 1) t *= 2;
    vector<C> z(t);
    for (int i = 0; i < a.size(); i++) z[i].real(a[i]);
    for (int i = 0; i < b.size(); i++) z[i].imag(b[i]);
    fft(z, false);
    vector<C> w(t);
    for (int i = 0; i < t; i++) {
      C p = (z[i] + conj(z[(t - i) % t])) * C(0.5L, 0.0L);
      C q = (z[i] - conj(z[(t - i) % t])) * C(0.0L, -0.5L);
      w[i] = p * q;
    }
    fft(w, true);
    vector<long long> ans(a.size() + b.size() - 1);
    for (int i = 0; i < ans.size(); i++) {
      ans[i] = round(w[i].real());
    }
    return ans;
  }

  vector<mint> convolution(vector<mint> a, vector<mint> b) {
    int t = 1;
    while (t < a.size() + b.size() - 1) t *= 2;
    vector<C> A(t), B(t);
    for (int i = 0; i < a.size(); i++) A[i] = C((int)a[i] & 0x7fff, (int)a[i] >> 15);
    for (int i = 0; i < b.size(); i++) B[i] = C((int)b[i] & 0x7fff, (int)b[i] >> 15);
    fft(A, false);
    fft(B, false);
    vector<C> X(t), Y(t);
    for (int i = 0; i < t; i++) {
      int j = (t - i) % t;
      C AL = (A[i] + conj(A[j])) * C(0.5, 0);
      C AH = (A[i] - conj(A[j])) * C(0, -0.5);
      C BL = (B[i] + conj(B[j])) * C(0.5, 0);
      C BH = (B[i] - conj(B[j])) * C(0, -0.5);
      X[i] = AL * BL + AH * BL * C(0, 1);
      Y[i] = AL * BH + AH * BH * C(0, 1);
    }
    fft(X, true);
    fft(Y, true);
    vector<mint> ans(a.size() + b.size() - 1);
    for (int i = 0; i < ans.size(); i++) {
      long long l = (long long)round(X[i].real()) % MOD;
      long long m = ((long long)round(X[i].imag()) + (long long)round(Y[i].real())) % MOD;
      long long h = (long long)round(Y[i].imag()) % MOD;
      ans[i] = (l + (m << 15) + (h << 30)) % MOD;
    }
    return ans;
  }
};
FFT<1 << 22> fft;

mint alt(int n) {
  return n % 2 == 0 ? 1 : MOD - 1;
}

int main() {
  int X, Y, Z; cin >> X >> Y >> Z;
  vector<mint> A(1 << 20);
  vector<mint> B(1 << 20);
  for (int i = 0; i < A.size(); i++) {
    A[i] = alt(i) * R(i);
    B[i] = R(i) * F(i + X - 1) * F(i + Y - 1) * F(i + Z - 1) * R(i - 1) * R(i - 1) * R(i - 1);
  }
  A = fft.convolution(A, B);
  mint ans = 0;
  rep(i, A.size() / 2) {
    ans += A[i] * F(i);
  }
  ans *= R(X) * R(Y) * R(Z);
  cout << ans << endl;

  /*
  {
  mint ans;
  for (int k = 0; k <= 8000; k++) {
    mint v;
    for (int i = 0; i <= k; i++) {
      int j = k - i;
      mint s = i % 2 == 0 ? 1 : MOD - 1;
      // ans += s * C(k, i) * H(k - i, X) * H(k - i, Y) * H(k - i, Z);
      mint tmp = s * R(i) * R(j);
      tmp *= F(j + X - 1) * R(j - 1);
      tmp *= F(j + Y - 1) * R(j - 1);
      tmp *= F(j + Z - 1) * R(j - 1);
      v += tmp;
    }
    ans += v * F(k);
  }
  ans *= R(X) * R(Y) * R(Z);
  cout << ans << endl;
  }
  */
}
0