結果

問題 No.2442 線形写像
ユーザー 👑 emthrmemthrm
提出日時 2023-08-25 21:26:16
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,997 bytes
コンパイル時間 2,690 ms
コンパイル使用メモリ 244,556 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-25 21:26:20
合計ジャッジ時間 3,829 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 21 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

template <typename T>
struct Matrix {
  explicit Matrix(const int m, const int n, const T def = 0)
      : data(m, std::vector<T>(n, def)) {}

  int nrow() const { return data.size(); }
  int ncol() const { return data.front().size(); }

  Matrix pow(long long exponent) const {
    const int n = nrow();
    Matrix<T> res(n, n, 0), tmp = *this;
    for (int i = 0; i < n; ++i) {
      res[i][i] = 1;
    }
    for (; exponent > 0; exponent >>= 1) {
      if (exponent & 1) res *= tmp;
      tmp *= tmp;
    }
    return res;
  }

  inline const std::vector<T>& operator[](const int i) const { return data[i]; }
  inline std::vector<T>& operator[](const int i) { return data[i]; }

  Matrix& operator=(const Matrix& x) = default;

  Matrix& operator+=(const Matrix& x) {
    const int m = nrow(), n = ncol();
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < n; ++j) {
        data[i][j] += x[i][j];
      }
    }
    return *this;
  }

  Matrix& operator-=(const Matrix& x) {
    const int m = nrow(), n = ncol();
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < n; ++j) {
        data[i][j] -= x[i][j];
      }
    }
    return *this;
  }

  Matrix& operator*=(const Matrix& x) {
    const int m = nrow(), l = ncol(), n = x.ncol();
    std::vector<std::vector<T>> res(m, std::vector<T>(n, 0));
    for (int i = 0; i < m; ++i) {
      for (int k = 0; k < l; ++k) {
        for (int j = 0; j < n; ++j) {
          res[i][j] += data[i][k] * x[k][j];
        }
      }
    }
    data.swap(res);
    return *this;
  }

  Matrix operator+(const Matrix& x) const { return Matrix(*this) += x; }
  Matrix operator-(const Matrix& x) const { return Matrix(*this) -= x; }
  Matrix operator*(const Matrix& x) const { return Matrix(*this) *= x; }

 private:
  std::vector<std::vector<T>> data;
};

int main() {
  int n; cin >> n;
  vector<uint64_t> a(1 << n); REP(i, 1 << n) cin >> a[i];
  if (a[0] != 0) {
    cout << "No\n";
    return 0;
  }
  FOR(i, 1, 1 << n) {
    __int128_t x = 0;
    REP(j, n) {
      if (i >> j & 1) x += a[1 << j];
    }
    if (x != a[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
0