結果

問題 No.2251 Marking Grid
ユーザー kumakumakumakuma
提出日時 2023-03-13 18:53:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,527 bytes
コンパイル時間 2,764 ms
コンパイル使用メモリ 219,248 KB
実行使用メモリ 65,676 KB
最終ジャッジ日時 2023-10-18 11:12:48
合計ジャッジ時間 11,378 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = 3.141592653589793;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll mod = 998244353;
  ll H, W;
  cin >> H >> W;
  vector<ll> power(H + W + 1, 1);
  for (ll i = 0; i < H + W; ++i) {
    power.at(i + 1) = power.at(i) * 2 % mod;
  }
  vector<vector<ll>> A(H, vector<ll>(W));
  vector<vector<ll>> num;
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      cin >> A.at(i).at(j);
      num.push_back({A.at(i).at(j), i, j});
    }
  }
  sort(rrng(num));
  ll r_num = W, c_num = H;
  vector<bool> row(W, false);
  vector<bool> col(H, false);
  ll ans = 0;
  for (ll i = 0; i < num.size(); ++i) {
    vector<ll> n = num.at(i);
    ll h = n.at(1), w = n.at(2);
    if (col.at(h) && row.at(w)) {
      continue;
    }
    if (!col.at(h)) {
      col.at(h) = true;
      c_num -= 1;
    }
    if (!row.at(w)) {
      row.at(w) = true;
      r_num -= 1;
    }
    ans += (n.at(0) * power.at(r_num) % mod) * power.at(c_num) % mod;
    ans %= mod;
  }
  cout << ans << "\n";
}
//0011
//1100
//1100
//0011

//0101
//1010
//1010
//0101
0