結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー V_MelvilleV_Melville
提出日時 2021-11-21 20:20:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 6,076 ms
コンパイル使用メモリ 311,660 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 06:14:25
合計ジャッジ時間 9,641 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 36 ms
4,376 KB
testcase_09 AC 36 ms
4,376 KB
testcase_10 AC 36 ms
4,380 KB
testcase_11 AC 28 ms
4,376 KB
testcase_12 AC 38 ms
4,384 KB
testcase_13 AC 37 ms
4,380 KB
testcase_14 AC 185 ms
4,380 KB
testcase_15 AC 189 ms
4,380 KB
testcase_16 AC 192 ms
4,376 KB
testcase_17 AC 193 ms
4,380 KB
testcase_18 AC 199 ms
4,376 KB
testcase_19 AC 191 ms
4,376 KB
testcase_20 AC 133 ms
4,376 KB
testcase_21 AC 150 ms
4,380 KB
testcase_22 AC 28 ms
4,380 KB
testcase_23 AC 181 ms
4,376 KB
testcase_24 AC 21 ms
4,380 KB
testcase_25 AC 50 ms
4,384 KB
testcase_26 AC 18 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,384 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 27 ms
4,380 KB
testcase_31 AC 25 ms
4,380 KB
testcase_32 AC 25 ms
4,376 KB
testcase_33 AC 23 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::vector;
using ll = long long;
using mint = modint998244353;

vector<vector<mint>> matmul(vector<vector<mint>>& A, vector<vector<mint>>& B) {
	int n = A.size();
	vector C(n, vector<mint>(n));
	rep(i, n)rep(j, n)rep(k, n) C[i][k] += A[i][j] * B[j][k];
	return C;
}

vector<vector<mint>> matexp(vector<vector<mint>>& A, ll b) {
	int n = A.size();
	vector Z(n, vector<mint>(n));
	rep(i, n) Z[i][i] = 1;
	while (b > 0) {
		if (b & 1) Z = matmul(Z, A);
		A = matmul(A, A);
		b /= 2;
	}
	return Z;
}

int main() {
	int n, m;
	ll t;
	cin >> n >> m >> t;
	
	vector A(n, vector<mint>(n));
	rep(i, m) {
		int s, t;
		cin >> s >> t;
		A[s][t] = A[t][s] = 1;
	}
	
	A = matexp(A, t);
	
	cout << A[0][0].val() << '\n';
	
	return 0;
}
0