結果

問題 No.2445 奇行列式
ユーザー hiromi_ayasehiromi_ayase
提出日時 2023-08-26 08:31:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,223 bytes
コンパイル時間 5,106 ms
コンパイル使用メモリ 315,256 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-26 08:31:17
合計ジャッジ時間 10,427 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO                \
  ios::sync_with_stdio(false); \
  cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;

using mint = atcoder::modint;

using M = vector<vector<__int128>>;

__int128 det(M a, int n, bool flg) {
  if (n == 1) {
    return a[0][0];
  }
  i64 ret = 0;

  for (auto i : views::iota(0, n)) {
    M sa;
    for (auto j : views::iota(0, n-1)) {
      sa.push_back(vector<__int128>());
      int p = 0;
      for (auto k : views::iota(0, n)) {
        if (k == i) continue;
        sa[j].push_back(a[j + 1][k]);
      }
    }
    i64 f = flg && i % 2 ? -1 : 1;
    ret += f * a[0][i] * det(sa, n - 1, flg);
  }
  return ret;
}

int main() {
  FAST_IO

  int n, b;
  cin >> n >> b;

  M a;
  for (auto i : views::iota(0, n)) {
    a.push_back(vector<__int128>());
    for (auto j : views::iota(0, n)) {
      long v;
      cin >> v;
      a[i].push_back(v);
    }
  }

  auto x = det(a, n, true);
  auto y = det(a, n, false);

  auto ret = (long)((y-x)/2%b);
  cout << ret << endl;

}
0