結果

問題 No.2251 Marking Grid
ユーザー 👑 colognecologne
提出日時 2023-03-21 14:29:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 393 ms / 3,000 ms
コード長 543 bytes
コンパイル時間 5,959 ms
コンパイル使用メモリ 322,820 KB
実行使用メモリ 16,116 KB
最終ジャッジ日時 2023-10-18 18:26:20
合計ジャッジ時間 10,921 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 332 ms
16,116 KB
testcase_23 AC 393 ms
16,116 KB
testcase_24 AC 15 ms
4,348 KB
testcase_25 AC 392 ms
16,116 KB
testcase_26 AC 89 ms
7,412 KB
testcase_27 AC 216 ms
16,116 KB
testcase_28 AC 12 ms
4,348 KB
testcase_29 AC 231 ms
16,116 KB
testcase_30 AC 75 ms
7,412 KB
testcase_31 AC 51 ms
4,984 KB
testcase_32 AC 27 ms
4,348 KB
testcase_33 AC 328 ms
16,116 KB
testcase_34 AC 36 ms
4,984 KB
testcase_35 AC 162 ms
10,960 KB
testcase_36 AC 207 ms
10,960 KB
testcase_37 AC 277 ms
16,116 KB
testcase_38 AC 16 ms
4,348 KB
testcase_39 AC 11 ms
4,348 KB
testcase_40 AC 148 ms
10,960 KB
testcase_41 AC 75 ms
7,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 = N+M - 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;
}
0