結果
| 問題 | No.2251 Marking Grid |
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2023-03-17 21:57:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 259 ms / 3,000 ms |
| コード長 | 771 bytes |
| 記録 | |
| コンパイル時間 | 3,212 ms |
| コンパイル使用メモリ | 282,956 KB |
| 実行使用メモリ | 15,696 KB |
| 最終ジャッジ日時 | 2026-06-29 23:40:18 |
| 合計ジャッジ時間 | 6,907 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
int h,w;
cin>>h>>w;
vector a(h,vector<int>(w));
vector<pair<int,int>> t;
rep(i,h){
rep(j,w){
cin>>a[i][j];
t.emplace_back(i,j);
}
}
sort(t.rbegin(),t.rend(),[&](pair<int,int> x,pair<int,int> y){
return a[x.first][x.second]<a[y.first][y.second];
});
int rem = h+w-1;
mint ans = 0;
dsu D(h+w);
rep(i,t.size()){
int x = t[i].first,y = t[i].second;
if(D.same(x,h+y))continue;
D.merge(x,h+y);
rem--;
ans += mint(2).pow(rem) * a[x][y];
}
cout<<ans.val()<<endl;
return 0;
}
沙耶花