結果

問題 No.1878 union-find の数え上げ
ユーザー SSRSSSRS
提出日時 2022-03-18 21:57:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 192,924 KB
最終ジャッジ日時 2025-01-28 10:21:16
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N;
  cin >> N;
  vector<int> p(N, -1);
  for (int i = 1; i < N; i++){
    cin >> p[i];
    p[i]--;
  }
  long long ans = 1;
  for (int i = 1; i < N; i++){
    if (p[i] != 0){
      ans *= 2;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}
0