結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー Kome_soudou
提出日時 2021-11-27 17:10:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 178,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-30 08:10:05
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
  int64_t N, M, T;
  cin >> N >> M >> T;
  int64_t mod = 998244353;
  
  int64_t s, t;
  vector<vector<int64_t>> G(N);
  for(int64_t i = 0; i < M; i++)
  {
    cin >> s >> t;
    G.at(s).push_back(t);
    G.at(t).push_back(s);
  }
  
  vector<int64_t> ans(N);
  ans.at(0) = 1;
  for(int64_t day = 1; day <= T; day++)
  {
    vector<bool> pass(N);
    pass.at(0) = true;
    vector<int64_t> count(N);
    queue<int64_t> q;
    q.push(0);
    while(!q.empty())
    {
      int64_t p = q.front();
      q.pop();
      for(int64_t g : G.at(p))
      {
        count.at(g) += ans.at(p);
        count.at(g) %= mod;
        if(!pass.at(g))
        {
          pass.at(g) = true;
          q.push(g);
        }
      }
    }
    
    for(int64_t i = 0; i < N; i++) ans.at(i) = count.at(i);
  }
  
  cout << ans.at(0) << endl;
  return 0;
}
0