結果
| 問題 | No.3412 Christmas Tree Coloring |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-19 17:05:33 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 155 ms / 2,000 ms |
| コード長 | 475 bytes |
| 記録 | |
| コンパイル時間 | 1,514 ms |
| コンパイル使用メモリ | 162,640 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-19 17:05:39 |
| 合計ジャッジ時間 | 4,961 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e5, mod=998244353;
ll fpow(ll b, ll p)
{
ll ret=1;
while(p)
{
if(p&1)
ret = ret * b % mod;
b=b*b%mod;
p/=2;
}
return ret;
}
int a[N];
int main()
{
int n;
cin>>n;
for(int i=0, x, y; i<n-1; i++)
{
cin >> x >> y;
a[x]++, a[y]++;
}
ll ans=0;
for(int i=1; i<=n; i++)
ans = (ans + fpow(2, a[i]) - (a[i]==n-1? 2: 0))%mod;
cout << ans;
}