結果

問題 No.2251 Marking Grid
ユーザー 👑 colognecologne
提出日時 2023-03-21 14:28:59
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 545 bytes
コンパイル時間 5,803 ms
コンパイル使用メモリ 322,956 KB
実行使用メモリ 16,164 KB
最終ジャッジ日時 2023-10-18 18:26:09
合計ジャッジ時間 13,704 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 = 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;
}
0