結果
| 問題 |
No.2494 Sum within Components
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-01 10:46:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 680 bytes |
| コンパイル時間 | 3,913 ms |
| コンパイル使用メモリ | 253,892 KB |
| 最終ジャッジ日時 | 2025-02-16 15:58:56 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}