結果

問題 No.2405 Minimal Matrix Decomposition
ユーザー 👑 amentorimaruamentorimaru
提出日時 2023-07-29 11:03:35
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,631 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 126,620 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 22:48:57
合計ジャッジ時間 6,299 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 43 ms
5,376 KB
testcase_05 AC 214 ms
6,272 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 100 ms
5,376 KB
testcase_11 AC 128 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 29 ms
5,376 KB
testcase_14 AC 33 ms
5,376 KB
testcase_15 AC 12 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 54 ms
5,376 KB
testcase_18 AC 40 ms
5,376 KB
testcase_19 AC 39 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 100 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 8 ms
5,376 KB
testcase_26 AC 76 ms
5,376 KB
testcase_27 AC 26 ms
5,376 KB
testcase_28 AC 70 ms
5,376 KB
testcase_29 AC 22 ms
5,376 KB
testcase_30 AC 86 ms
5,376 KB
testcase_31 AC 36 ms
5,376 KB
testcase_32 AC 7 ms
5,376 KB
testcase_33 AC 64 ms
5,376 KB
testcase_34 AC 16 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 28 ms
5,376 KB
testcase_37 AC 42 ms
5,376 KB
testcase_38 AC 49 ms
5,376 KB
testcase_39 AC 78 ms
5,376 KB
testcase_40 AC 36 ms
5,376 KB
testcase_41 AC 6 ms
5,376 KB
testcase_42 AC 85 ms
5,376 KB
testcase_43 AC 24 ms
5,376 KB
testcase_44 AC 22 ms
5,376 KB
testcase_45 AC 10 ms
5,376 KB
testcase_46 AC 22 ms
5,376 KB
testcase_47 AC 26 ms
5,376 KB
testcase_48 AC 10 ms
5,376 KB
testcase_49 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <unordered_set>
#include <atcoder/modint.hpp>

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
  ll p, n, m;
  cin >> p >> n >> m;
  modint::set_mod(p);
  vector a(n, vector<modint>(m));
  vector ba(n, vector<modint>(m));
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      ll ta;
      cin >> ta;
      a[i][j] = ba[i][j] = ta;
    }
  }
  vector<vector<modint>> c(n);
  vector<vector<modint>> f;
  for (ll j = 0; j < m; j++) {
    ll ib = -1;
    for (ll i = 0; i < n; i++) {
      if (a[i][j] != 0) {
        ib = i;
        break;
      }
    }
    if (ib < 0)
      continue;
    f.push_back(a[ib]);
    for (ll i = 0; i < n; i++) {
      if (i == ib)
        continue;
      modint mul = a[i][j] / a[ib][j];
      c[i].push_back(mul);
      for (ll jj = j; jj < m; jj++) {
        a[i][jj] -= mul * a[ib][jj];
      }
    }
    c[ib].push_back(1);
    a[ib].assign(m, 0);
  }
  ll r = f.size();
  if (n * m > (n + m) * r) {
    cout << 2 << endl;
    cout << n << " " << r << endl;
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < r; j++) {
        cout << c[i][j].val() << " ";
      }
      cout << endl;
    }
    cout << r << " " << m << endl;
    for (ll i = 0; i < r; i++) {
      for (ll j = 0; j < m; j++) {
        cout << f[i][j].val() << " ";
      }
      cout << endl;
    }
  }
  else {
    cout << 1 << endl;
    cout << n << " " << m << endl;
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < m; j++) {
        cout << ba[i][j].val() << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
0