結果
| 問題 | No.2494 Sum within Components |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-01 10:46:17 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 680 bytes |
| 記録 | |
| コンパイル時間 | 3,015 ms |
| コンパイル使用メモリ | 277,044 KB |
| 実行使用メモリ | 17,408 KB |
| 最終ジャッジ日時 | 2026-07-02 08:10:21 |
| 合計ジャッジ時間 | 4,197 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
struct Fast {
Fast() {
std::cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << setprecision(10);
}
} fast;
#define rep(i, a, b) for (int(i) = (a); (i) < (int)(b); (i)++)
using mint = modint998244353;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n);
rep(i, 0, n) cin >> a[i];
dsu uf(n);
rep(i, 0, m) {
int u, v;
cin >> u >> v;
u--;
v--;
uf.merge(u, v);
}
mint ans = 1;
for (auto s : uf.groups()) {
mint sum = 0;
for (auto x : s) sum += a[x];
ans *= sum.pow(s.size());
}
cout << ans.val() << endl;
}