結果

問題 No.3412 Christmas Tree Coloring
コンテスト
ユーザー テナガザル
提出日時 2025-12-19 01:14:33
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,049 ms
コンパイル使用メモリ 102,556 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-19 01:14:38
合計ジャッジ時間 4,728 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    const int mod = 998244353;
    int n;
    cin >> n;
    vector<int> cnt(n);
    for (int i = 1; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++cnt[a];
        ++cnt[b];
    }
    vector<long long> p2(n);
    p2[0] = 1;
    for (int i = 0; i < n - 1; ++i) p2[i + 1] = p2[i] * 2LL % mod;
    long long ans = 0;
    for (int i = 0; i < n; ++i) ans = (ans + p2[cnt[i]]) % mod;
    cout << ans << endl;
}
0