結果
| 問題 | No.3412 Christmas Tree Coloring |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-19 15:25:45 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 607 bytes |
| 記録 | |
| コンパイル時間 | 5,320 ms |
| コンパイル使用メモリ | 335,080 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-19 15:25:53 |
| 合計ジャッジ時間 | 7,464 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using mint = modint998244353;
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int n;
cin >> n;
vector<int> deg(n);
rep(i, n-1) {
int a, b;
cin >> a >> b;
--a; --b;
++deg[a]; ++deg[b];
}
mint ans;
int cnt = 0;
rep(v, n) {
ans += mint(2).pow(deg[v]);
if (deg[v] == n-1) ++cnt;
}
ans -= 2*cnt;
cout << ans.val() << '\n';
return 0;
}