結果
| 問題 |
No.1750 ラムドスウイルスの感染拡大-hard
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2021-11-19 21:58:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 985 bytes |
| コンパイル時間 | 1,429 ms |
| コンパイル使用メモリ | 168,724 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-01 17:31:24 |
| 合計ジャッジ時間 | 3,285 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template <typename T>
vector<vector<T>> MatrixProduct(vector<vector<T>> vec1, vector<vector<T>> vec2){
int N = vec1.size(), M = vec2[0].size(), L = vec2.size();
vector<vector<T>> res(N,vector<T>(M,0));
rep(i,N) rep(j,M){
rep(k,L) res[i][j] += vec1[i][k] * vec2[k][j];
res[i][j] %= MOD;
}
return res;
}
int main(){
ll n,m,t;
cin >> n >> m >> t;
vector<vector<ll>> mult(n,vector<ll>(n,0));
rep(i,m){
int a,b;
cin >> a >> b;
mult[a][b] = mult[b][a] = 1;
}
vector<vector<ll>> a(1,vector<ll>(n,0));
a[0][0] = 1;
while(t){
if(t&1){
a = MatrixProduct(mult,a);
}
mult = MatrixProduct(mult,mult);
t >>= 1;
}
cout << a[0][0] << endl;
return 0;
}
houren