結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー bonKotsubonKotsu
提出日時 2022-07-25 23:23:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 1,513 bytes
コンパイル時間 4,368 ms
コンパイル使用メモリ 266,488 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 10:10:36
合計ジャッジ時間 8,485 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 5 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 31 ms
4,380 KB
testcase_10 AC 31 ms
4,380 KB
testcase_11 AC 23 ms
4,380 KB
testcase_12 AC 34 ms
4,376 KB
testcase_13 AC 31 ms
4,380 KB
testcase_14 AC 178 ms
4,380 KB
testcase_15 AC 182 ms
4,376 KB
testcase_16 AC 183 ms
4,380 KB
testcase_17 AC 185 ms
4,376 KB
testcase_18 AC 191 ms
4,380 KB
testcase_19 AC 183 ms
4,380 KB
testcase_20 AC 129 ms
4,380 KB
testcase_21 AC 143 ms
4,380 KB
testcase_22 AC 26 ms
4,380 KB
testcase_23 AC 174 ms
4,380 KB
testcase_24 AC 20 ms
4,380 KB
testcase_25 AC 47 ms
4,380 KB
testcase_26 AC 16 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 25 ms
4,380 KB
testcase_31 AC 24 ms
4,376 KB
testcase_32 AC 24 ms
4,380 KB
testcase_33 AC 24 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
template<class T>
void chmax(T& a, T b) { a = max(a, b); };
template<class T>
void chmin(T& a, T b) { a = min(a, b); };
using mint = modint998244353;

template<typename T>
struct Matrix {
  int h, w;
  vector<vector<T>> d;
  Matrix() {}
  Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector<T>(w,val)) {}
  Matrix& unit() {
    assert(h == w);
    rep(i,h) d[i][i] = 1;
    return *this;
  }
  const vector<T>& operator[](int i) const { return d[i];}
  vector<T>& operator[](int i) { return d[i];}
  Matrix operator*(const Matrix& a) const {
    assert(w == a.h);
    Matrix r(h, a.w);
    rep(i,h)rep(k,w)rep(j,a.w) {
      r[i][j] += d[i][k]*a[k][j];
    }
    return r;
  }
  Matrix pow(ll t) const {
    assert(h == w);
    if (!t) return Matrix(h,h).unit();
    if (t == 1) return *this;
    Matrix r = pow(t>>1);
    r = r*r;
    if (t&1) r = r*(*this);
    return r;
  }
};

int main() {
  int n, m; ll t;
  cin >> n >> m >> t;
  Matrix<mint> d(n,n), x(n,1);
  x[0][0] = 1;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    d[a][b] = 1;
    d[b][a] = 1;
  }
  auto ans = d.pow(t)*x;
  cout << ans[0][0].val() << endl;
  


  
  return 0;
}
0