結果
| 問題 | No.2494 Sum within Components |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-07 00:03:38 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 553 bytes |
| 記録 | |
| コンパイル時間 | 1,982 ms |
| コンパイル使用メモリ | 178,240 KB |
| 実行使用メモリ | 17,408 KB |
| 最終ジャッジ日時 | 2026-04-03 17:46:40 |
| 合計ジャッジ時間 | 4,684 ms |
|
ジャッジサーバーID (参考情報) |
judge5_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <atcoder/dsu>
#include <atcoder/modint>
typedef atcoder::modint998244353 mint;
int main() {
std::cin.tie(nullptr) -> sync_with_stdio(false);
int n, m;
std::cin >> n >> m;
std::vector<int> a(n);
for(auto &el: a) std::cin >> el;
atcoder::dsu uf(n);
while(m--) {
int u, v;
std::cin >> u >> v;
uf.merge(--u, --v);
}
mint ans = 1;
for(const auto g: uf.groups()) {
mint res = 0;
for(const auto i: g) {
res += a[i];
}
ans *= res.pow(std::ssize(g));
}
std::cout << ans.val() << '\n';
}