結果
問題 |
No.2251 Marking Grid
|
ユーザー |
|
提出日時 | 2023-03-21 14:28:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 545 bytes |
コンパイル時間 | 5,794 ms |
コンパイル使用メモリ | 321,984 KB |
実行使用メモリ | 17,560 KB |
最終ジャッジ日時 | 2024-09-18 14:22:25 |
合計ジャッジ時間 | 13,996 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 15 RE * 22 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using Mint = atcoder::modint998244353; int main() { int N, M; cin >> N >> M; vector<tuple<int, int, int>> V; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) { int t; cin >> t; V.emplace_back(t, i, j + N); } sort(V.rbegin(), V.rend()); atcoder::dsu ufd(M + N); int c = 2 * N - 2; Mint ans = 0; for (auto [w, i, j] : V) { if (!ufd.same(i, j)) { ufd.merge(i, j); ans += w * (Mint(2).pow(c)); --c; } } cout << ans.val() << endl; }